-
SuggestionI'm struggling to find any example on the web of using EIP-1559 to send an ERC20 token (USDC in my case) I've seen an example for sending ETH in the Web3.js test suite but could not find one for ERC20 and EIP-1559. I haven't looked directly in the ethers.js tests yet but nothing surfaces on Google Currently using Web3.js but happy to switch to Ethers.js if I can get any help with this presumably very common use case |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
If you are on a network that supports EIP-1559, it is automatically used. If you are on a network that does not support EIP-1559, but want to force it to try (it will fail immediately), just pass Long story short, this isn’t something you should generally have to worry about. :) |
Beta Was this translation helpful? Give feedback.
-
Hi @ricmoo Is there a single actually working example of sending USDC via ethers.js (using Infura or some such service) ? I am about to give up. My transactions are getting permanently stuck after getting back the transaction hash, so at least I know the transaction is well formed. I tried to get the gas calculated using all kinds of recipes on the web for web3js and it would always say my balance is too low or the gas is too low. Finally I picked a static vaue of gasLimit: web3.utils.toHex(10000000) which I believe is very high and my transaction went thru but got stuck. Now I can't even get the transaction count despite passing "pending" to getTransactionCount. I'm ready to DUMP Web3js and forget it forever, and replace with ethers.js to save my sanity, assuming there is at least one fully working example of sending USDC over Ethereum. Here is how my transaction looks like: let txData = tokenContract.methods.transfer(toAddress, amount * 1000000).encodeABI()
const txParams = {
from: fromAddress,
nonce: web3.utils.toHex(count),
gasLimit: web3.utils.toHex(10000000), // in ETH while the amount is in USDC (WTF)
to: tokenContract._address,
value: 0x00,
data: txData,
chainId: config.network.chainId
}; I am signing the transaction with the private key and prepending 0x to it then sending it via sendSignedTransaction Sorry, my code is currently all in web3js and I don't know ethers.js enough yet to try it but what would really help me is an example that actually works for sending USDC from my wallet address to another address I own For now 4 transactions have been stuck and I don't even know how to look up their state. The docs are horrific, outdated, too many broken APIs, etc Help :) Please. |
Beta Was this translation helpful? Give feedback.
-
@ricmoo I ended up implementing EIP-3009. Doing the gas estimates and having to have ETH in the wallet to make money go from A to B is ridiculous, so I'm glad they had thought of meta transactions and that just worked for me, with amazing help from Ethers (for signing the typed data)! It took a while for me to figure out how implement as a pure API since the example on Ethereum.org assumed a Metamask wallet injected into the window object in the browser, but I'm doing everything server side, past authentication/authorization. I am stunned that a spec for a "standard" assume the use of a 3rd party tool and/or that users will be self hosting their wallets. I guess I'm new to the Ethereum ecosystem and not used to all this chaos and arbitrariness. But Ethers saved the day so thank you for that! |
Beta Was this translation helpful? Give feedback.
@ricmoo I ended up implementing EIP-3009. Doing the gas estimates and having to have ETH in the wallet to make money go from A to B is ridiculous, so I'm glad they had thought of meta transactions and that just worked for me, with amazing help from Ethers (for signing the typed data)! It took a while for me to figure out how implement as a pure API since the example on Ethereum.org assumed a Metamask wallet injected into the window object in the browser, but I'm doing everything server side, past authentication/authorization. I am stunned that a spec for a "standard" assume the use of a 3rd party tool and/or that users will be self hosting their wallets. I guess I'm new to the Ethereum ec…