当我在其他钱包地址发送一些余额时,我无法更新我的以太币钱包余额

时间:2018-06-04 13:15:46

标签: ether

我正在使用ethers npm包访问我的以太币钱包并使用以太币钱包进行交易。 当我将钱包里的一些数量的以太币送到管理员钱包时,sendTransaction()方法会给出成功的回复,但我的以太坊钱包余额没有更新。 功能如下:

var privateKey = event.key || '';
var wallet = new ethers.Wallet(privateKey);
wallet.provider = ethers.providers.getDefaultProvider("homestead");

    var transaction = {
      // Recommendation: omit nonce; the provider will query the network
      // nonce: 0,

      // Gas Limit; 21000 will send ether to another use, but to execute contracts
      // larger limits are required. The provider.estimateGas can be used for this.
      gasLimit: 21000,
      //1000000

      // Recommendations: omit gasPrice; the provider will query the network
      gasPrice: ethers.utils.bigNumberify("1000000000"),

      // Required; unless deploying a contract (in which case omit)
      to: event.to,

      // Optional
      data: "0x",

      // Optional
      value: ethers.utils.parseEther(event.amount)

      // Recommendation: omit chainId; the provider will populate this
      // chaindId: providers.Provider.chainId.homestead
    };

    var amount = ethers.utils.parseEther(event.amount);
    var to = event.to;
    var options = {
       gasLimit: 21000,
       gasPrice: ethers.utils.bigNumberify("1000000000")
    };

    var sendPromise = wallet.send(to, amount, options);

    sendPromise.then(function(transactionHash) {
       console.log(transactionHash);
       callback(null, {
            "statusCode":200,
            "data": transactionHash
        });
    });

任何人都有想法吗?

0 个答案:

没有答案