Error using EtherJS: this.provider.getTransactionCount is not a function

0 votes

I'm trying to use Ether.js in React-Native environment to send ether. I followed the example on the Etherjs guide.

This is my code:

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);
    });

When I throw this function i will get the following error:

this.provider.getTransactionCount is not a function

How I could solve this?

Sep 26, 2018 in Blockchain by slayer
• 29,040 points
71 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

With this line it should work fine:

wallet.provider = new ethers.providers.InfuraProvider('rinkeby','rinkebyKeyAPI');
answered Sep 26, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
1 answer

TypeError: XMLHttpRequest is not a function when using web3 on meteor server side

I had the same problem. Instead ethereum:web3 Meteor package ...READ MORE

answered Oct 10, 2018 in Blockchain by Omkar
• 65,850 points
41 views
0 votes
1 answer

Truffle tutorials "Error:recipient address is not a contract address"

It appears like you have already migrated ...READ MORE

answered Aug 8, 2018 in Blockchain by slayer
• 29,040 points
157 views
0 votes
1 answer

Bitcoinjs-lib getAddress not a function error

You need to pass network parameter to ...READ MORE

answered Aug 27, 2018 in Blockchain by slayer
• 29,040 points
192 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
65 views
0 votes
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,320 points
43 views
0 votes
1 answer

Solidity mocha : address is not a contract error

Try the following: // Initialize contract variable with ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 27,620 points
25 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.