Sending transaction with data on Coinbase Wallet Mobile fails
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:
- Removing the transaction data works
- I've been able to send transaction data of only "1", but even simple data like "test" does not work
- Adjusting transaction parameters like gas, network, nonce etc. have not worked
Code Snippet
No response
Contract ABI
No response
Errors
could not coalesce error (error={ "code": -32603, "data": { "originalError": { } }, "message": "Failed to sign transaction" }, payload={ "id": 6, "jsonrpc": "2.0", "method": "eth_sendTransaction", "params": [ { "data": "0x000000000...", "from": "0xafac00f3b608ddc9df671225029844d76a10af6d", "gas": "0x8f77", "to": "0x5493db14a2b6fd71b531fa1cfc752fdfad734acd", "value": "0x16bcc41e900000" } ] }, code=UNKNOWN_ERROR, version=6.13.0)
Environment
Ethereum (mainnet/ropsten/rinkeby/goerli), Other (please specify)
Environment (Other)
Coinbase Wallet Mobile Browser
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,
});
I am also experiencing this issue. My app, eternal.social is encoding data and the transactions are failaing speicifically in the mobile browser. I would appreciate some attention on this, as coinbase wallet is one of the most popular wallets for a smooth user experience.