Ethers.js: How to set gas fee in caontract

Created on 13 Apr 2020  路  8Comments  路  Source: ethers-io/ethers.js

Hey Richard,
I experimented in different ways. But the problem was not solved. (gas price ,gas limit)
I 've also tried this, too - doc
i use someFunction ->error someFunction not function!
aprove ->error value input
i checked the all functions abi .

discussion

All 8 comments

That should work. Can you post your code? It should look something like:

const abi = [ "function transfer(address, address, uint)" ];

const abi = [ "function transfer(address, uint)" ];
const contract = new Contract(contractAddress, abi, signer);
const overrides = {
    gasLimit: 450000,
    gasPrice: 9000000000
};
contract.transfer(toAddress, 1234, overrides);

Send me some code and I can help point you in the right direction. :)

ok this is my code
1
and
code2
my code error:
errormy2
your code error:
erroryourcode-2

Quick note: there is no difference between your contract and contractWithSigner, since they are both connected to wallet. That's not a problem though, just a quick point that you could use your contract variable directly.

Oh, sorry... There was a typo in my original code. If this is an ERC-20 contract, the signature should be "function transfer(address, uint256)". This is failing because you are passing the transaction as the third variable, which is expecting a number. I've updated that comment. Try the new code?

ohh.yes thank you.
this code work for me->
ok send
I sent the transaction a few minutes ago
tx.hash

But. how to change gas price and ?

In your last sample:

// Here -------------------------------------v
contract.transfer(toAddress, numberOfTokens, transaction).then(function(tx) {
     console.log(tx);
});

Yes ,it is , Thank you.

Closing this now. Let me know if you have any other problems.

Thanks! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ricmoo picture ricmoo  路  24Comments

dev1644 picture dev1644  路  42Comments

Tower450 picture Tower450  路  25Comments

fjrojasgarcia picture fjrojasgarcia  路  28Comments

MicahZoltu picture MicahZoltu  路  24Comments