Closed xqingWong closed 5 months ago
Modified to: EthereumProvider.init({ ... optionalMethods: ['eth_sendTransaction', 'personal_sign', 'wallet_switchEthereumChain'] })
Calling the wallet_switchEthereumChain method gives an error: w4.startsWith is not a function
I get the same error, did you figure out anything? @xqingWong
please share a minimal reproducible example + steps to reproduce. Thanks!
demo: import { ref } from 'vue' import { EthereumProvider } from '@walletconnect/ethereum-provider'
const provider = ref() async function getProvider () { provider.value = await EthereumProvider.init({ projectId: 'you projectId', showQrModal: true, optionalChains: [ 11155111, 421611, 42161, 1 ], optionalMethods: ['eth_sendTransaction', 'personal_sign', 'wallet_switchEthereumChain'] }) } getProvider()
async function changeChain () { try { await provider.value.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: 1 }] }) console.log('success') } catch (err) { console.log('err:', err) } }
setTimeout(() => { changeChain() }, 60000)
Please run the demo to check the issue. The changeChain function needs to be executed after establishing the WalletConnect connection @glitch-txs
@rouzwelt
await provider.value.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: ’0x1‘ }]
})
Use the hexadecimal chain ID of the blockchain.
Describe the bug Using the @walletconnect/ethereum-provider plugin, version 2.11.2 Create the provider: EthereumProvider.init({ ... methods: ['eth_sendTransaction', 'personal_sign', 'wallet_switchEthereumChain'] }) But when calling the wallet_switchEthereumChain method, I get the error 'w5.startsWith is not a function'
SDK Version (if relevant)
Desktop (please complete the following information):
Additional context Can't quite figure out what's wrong.