Skip to content

Transaction failed only with USDC #2129

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

You must be logged in to vote

Hey @rvmelkonian, when you are working with various ERC20 tokens, you have to see if you are using proper decimals of an ERC20 token. Usually most of ERC20 tokens have decimals as 18. Hence the const amount = ethers.utils.parseUnits(amountToSend); defaults to 18. However USDC is having decimals as 6. So unknowingly you are trying to send 0.1 * 10**18 while you should be doing 0.1 * 10**6.

If you mention 6 as decimals (or dynamically query the decimals) then your tx should success.

const amount = ethers.utils.parseUnits(amountToSend, 6);`

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@0xmovses
Comment options

@Minhaj-ul-abidin
Comment options

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