Abigail
December 14, 2023, 6:39am
1
SDK Version: “@web3auth /base”: “^7.1.0”, “@web3auth /wallet-connect-v2-adapter”: “^7.1.1”, “@walletconnect /modal”: “^2.6.2”
Platform: Mobile Chrome/Safari(PWA)
Unable to addChain or switchChain, is it supported?
connectTo(WALLET_ADAPTERS.WALLET_CONNECT_V2, {})
is fine, but addChain or switchChain,all unable open wallet, how do i?
Also web3auth.authenticateUser(), unable open wallet to sign, any ideas?
vjgee
December 14, 2023, 7:26am
2
@Abigail Welcome Aboard!
Could you share your implementation code and which example you are using to guide your code?
Abigail
December 15, 2023, 6:57am
3
Hello it is my code.
Init
// VITE_CHAIN_ID='0xaa37dc'
// VITE_RPC_TARGET='https://sepolia.optimism.io'
// VITE_DISPLAY_NAME='OP Sepolia'
// VITE_BLOCK_EXPLORER='https://sepolia-optimistic.etherscan.io'
// VITE_TICKER='ETH'
// VITE_TICKER_NAME='OP Sepolia'
const web3AuthNetwork = config.VITE_WEB3AUTH_NETWORK
const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: config.VITE_CHAIN_ID,
rpcTarget: config.VITE_RPC_TARGET,
displayName: config.VITE_DISPLAY_NAME,
blockExplorer: config.VITE_BLOCK_EXPLORER,
ticker: config.VITE_TICKER,
tickerName: config.VITE_TICKER_NAME,
}
const w3a = new Web3AuthNoModal({
clientId,
web3AuthNetwork,
chainConfig,
sessionTime: 86400, // 24 hours
})
const defaultWcSettings = await getWalletConnectV2Settings(
CHAIN_NAMESPACES.EIP155,
[parseInt(config.VITE_CHAIN_ID, 16)],
config.VITE_WALLETCONNECT_PROJECT_ID
)
const walletConnectModal = new WalletConnectModal({
projectId: config.VITE_WALLETCONNECT_PROJECT_ID,
})
const walletConnectV2Adapter = new WalletConnectV2Adapter({
adapterSettings: {
qrcodeModal: walletConnectModal,
...defaultWcSettings.adapterSettings,
},
loginSettings: { ...defaultWcSettings.loginSettings },
})
w3a.configureAdapter(walletConnectV2Adapter)
// init()
Connect.
async walletConnectV2Login() {
await w3a.connectTo(WALLET_ADAPTERS.WALLET_CONNECT_V2, {})
await w3a.addChain({
decimals: 18,
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: config.VITE_CHAIN_ID,
rpcTarget: config.VITE_RPC_TARGET,
displayName: config.VITE_DISPLAY_NAME,
blockExplorer: config.VITE_BLOCK_EXPLORER,
ticker: config.VITE_TICKER,
tickerName: config.VITE_TICKER_NAME,
})
// await w3a.switchChain({chainId: config.VITE_CHAIN_ID})
// await w3a.authenticateUser()
}
I connect to metamask(connectTo). It’s fine.But w3a.addChain() not switch to the metamask and nothing happens. Did I write something wrong somewhere?
vjgee
December 15, 2023, 7:40am
4
Your issue has been forwarded to our team and we will get back with an update.