我试图在React中使用Ether.js --本地环境来发送以太。我学习了以太指南上的例子。
这是我的密码:
let privateKey = 'walletPrivateKey';
let destinationAddress = '0xa43cBF460670deA2AcC7642bBF71DBe867dB2e06';
var wallet = new ethers.Wallet(privateKey,['rinkeby','rinkebyKeyAPI']);
console.log('Address: ' + wallet.address);
console.log(wallet);
var transaction = {
gasLimit: 1000000,
gasPrice: ethers.utils.bigNumberify("20000000000"),
to: "0xa43cBF460670deA2AcC7642bBF71DBe867dB2e06",
data: "0x",
value: ethers.utils.parseEther("0.000666"),
};
let sendTransactionPromise = wallet.sendTransaction(transaction);
sendTransactionPromise.then(function(transactionHash) {
console.log(transactionHash);
});当我抛出这个函数时,我会得到以下错误:
this.provider.getTransactionCount不是一个函数
我怎么能解决这个问题?
发布于 2018-02-05 14:41:00
主要问题与提供程序设置有关。有了这一行,一切都很好:
wallet.provider = new ethers.providers.InfuraProvider('rinkeby','rinkebyKeyAPI');https://stackoverflow.com/questions/48621241
复制相似问题