coinbase-wallet-sdk icon indicating copy to clipboard operation
coinbase-wallet-sdk copied to clipboard

Confirm payment txn request on Coinbase Wallet mobile app reflects wrong Ethereum chain

Open jremi opened this issue 3 years ago • 3 comments

Hi everyone,

Most likely this is something trivial and I am just mis-configuring...

In summary: Everything is working great in regards to the actual wallet link communicating with the Coinbase Wallet mobile app (Coinbase Wallet for iOS - v25.8.555).

My issue is that I am attempting to test everything on Rinkeby testnet and it seems that regardless of pointing the RPC URL and chain id to rinkeby on Wallet Link, and despite having the Coinbase wallet configured for Rinkeby , I am still getting signing requests to the regular Ethereum mainnet chain... I could be wrong, but this seems to be the case.

The reason I mention this is due to the gas fee calculations that are appearing when I attempt to approve the signing transaction on the mobile app...


I have configured the Coinbase Wallet Settings for the following:

CONNECTIONS/DAPP BROWSER

  • Default Network: Rinkeby

ADVANCED

  • Advanced Settings > NETWORK : Testnet

The Coinbase Wallet shows under the balance "Rinkeby Ethereum" with 0.6 ETH which I deposited via the Rinkeby faucet.

On the dApp side.... I am configuring the walletLink provider like this...

...
const walletLink = new WalletLink({
  appName: 'My Cool dApp',
  appLogoUrl: 'https://my-cool-dapp.com/logo.png'
})
// My infura project id is not zeros. Just omitting for purposes of this public post.
const networkUrl = 'https://rinkeby.infura.io/v3/00000000000000000000000000000000`
const chainId = 4 // rinkeby
const provider = walletLink.makeWeb3Provider(networkUrl, chainId)
await provider.enable()
...

Long story short... on the dApp I scan the QR code using the Coinbase Wallet to connect.

This is SUCCESS.

The Coinbase Wallet now reflects under Settings > CONNECTIONS/ DAPP BROWSER > WalletLink (1) connection... The connection that appears in this menu is my app. That is great! When I disconnect, the disconnect also triggers in my dApp. So far so good. I have a working connect/disconnect. I also know its working because my dApp is able to show the connected Rinkeby address.

Ok so now, I attempt to trigger a contract method to perform a signing transaction against the provider...

I am doing something like this....

...
const tx = await this.contract.mint(this.account, amount, {
  value: utils.toWei((0.02).toString(), 'ether')
})
const receipt = await tx.wait()
...

When I do this also success! The Coinbase Wallet mobile app now triggers the "Confirm payment" screen...

Here is where things are getting stuck for me....

It says:

CHAIN
- Ethereum

$58.99
0.02 ETH
MINER FEE
$127.07 (0.0424041 ETH)

You don't have enough ETH to cover the miner fee. Deposit at least 0.0624041 ETH into your wallet and try again.

In summary:

I am totally confused.... The account has sufficient Rinkeby testnet funds.... (0.6 ETH) ....

It feels like the Confirm Payment transaction screen is looking at the mainnet and not testnet..

How do I continue and test?

Apologies for this long bit of text above, just wanted to try to get the reader into the same headspace as me. Most likely i'm just missing something trivial.

Much thanks to anyone who can provide any feedback!

🙏

-J

jremi avatar Feb 04 '22 17:02 jremi

Minor edit...

If I manually override the localStorage item -walletlink:https://www.walletlink.org:DefaultChainId which by default is set to 1 to 4 and then instantiate the provider using walletLink.makeWeb3Provider ...

✅ I am now able to get the Coinbase Wallet app to reflect the Rinkeby Chain .... That is great! .... I was able to actually make the transaction complete....

So I guess i'm now trying to figure out why I needed to manually override the -walletlink:https://www.walletlink.org:DefaultChainId 🤷

Any help would be greatly appreciated!

jremi avatar Feb 04 '22 18:02 jremi

@jremi I can reproduce this. This is a bug. You can temporarily workaround by just sending a wallet_switchEthereumChain request after initializing walletlink. There's code sample for that on https://github.com/walletlink/coinbase-wallet-sdk#switching--adding-alternative-evm-compatible-chains-with-eip-3085-and-eip-3326

We'll have an update available shortly.

brendanww avatar Feb 04 '22 22:02 brendanww

@brendanww thank you so much for your prompt reply and review of this... Greatly appreciated ... I will be on the lookout for the upcoming package update.

🙏

jremi avatar Feb 04 '22 22:02 jremi

https://github.com/coinbase/coinbase-wallet-sdk/issues/612

bangtoven avatar Jan 11 '23 00:01 bangtoven