Skip to content

How to set the gas price when I send ERC20 tokens #3346

Answered by zemse
web3dapp asked this question in Q&A
Discussion options

You must be logged in to vote

When I send ERC20 token using the "transfer" function, I don't need to handle the stuff like gas price, nonce etc. Are they handled by ethers.js?

Yeah, ethers.js tries to populate all the things needed for tx, like gas price, nonce, gas limit. If you want to provide a value for that you can pass an override for it. Docs about overrides are here.

Example code to pass gasPrice override:

const tx = await contract.transfer(targetAddress, numberOfTokens, { gasPrice: ethers.utils.parseUnits('15', 'gwei') })

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@web3dapp
Comment options

@zemse
Comment options

zemse Sep 11, 2022
Collaborator

@web3dapp
Comment options

Answer selected by web3dapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants