Open comster opened 4 weeks ago
Hmmm. I haven’t used coinbase wallet. Is it a browser plugin, similar to MetaMask?
How are you creating the Signer?
Thanks for your help!
Ya, it's similar to MetaMask afaik. Again, it's only on mobile in their in app browser where this isn't working, which is strange. And if I remove the data
it works fine.
let provider = new ethers.BrowserProvider(window.ethereum);
let signer = await provider.getSigner();
const tx = await signer.sendTransaction({
to: toAddress,
value: ethers.parseEther(amount),
data: ethers.AbiCoder.defaultAbiCoder().encode([{"name":"_value","type":"string"}], [DATA_VALUE_UNENCODED])
});
And for DATA_VALUE_UNENCODED
of a single character string like "Z" works, but not for "ZA" 🤔
That’s is super weird. :p
I’m guessing no console? If it is on iOS can you connect it to Safari and see any other errors in the console?
Do they have a GitHub repo? With issues we can search?
No I don't think so. It's an embedded browser in their app. It's not open source. I've reached out to them but haven't had a response yet. Just curious if you have any tips on other things I could test or debug. I can't tell if this is an issue with my code, ethers, or the wallet provider. Smells like the wallet provider, but I assume others aren't having this issue. Otherwise I'm giving up and going to restart my project with the newer react components available 🤷 .
For anyone else experiencing this issue, it turns out I had to figure out the gasLimit
myself.
Any insight into where in the stack this issue is at? I assume it's the coinbase wallet not properly calculating the gaslimit themselves, based on the data/input size. It would be great to raise this issue with the appropriate channel to help resolve this.
const transactionRequest = {
to: address,
value: amount,
data: getEncodedEthData(data_str),
};
const estimatedGas = await signer.estimateGas(transactionRequest);
const gasLimit = estimatedGas * BigInt(1000) / BigInt(100); // 10x the gas price for coinbase mobile wallet
const tx = await signer.sendTransaction({
...transactionRequest,
gasLimit: gasLimit,
});
Ethers Version
6.13.2
Search Terms
coinbase
Describe the Problem
Trying to send a transaction with data, or a contract call, are not working on coinbase wallet mobile browser. It's working in the browser with coinbase wallet, and metamask, and metamask mobile. I approve the transaction, but then get an RPC error: "Failed to sign transaction".
Things I have done to debug:
Code Snippet
No response
Contract ABI
No response
Errors
Environment
Ethereum (mainnet/ropsten/rinkeby/goerli), Other (please specify)
Environment (Other)
Coinbase Wallet Mobile Browser