admin管理员组文章数量:1405553
I've been trying to integrate WalletConnect by following this documentation of web3-react.
The configuration that I'm using for the connector is as follows:
import { WalletConnectConnector } from '@web3-react/walletconnect-connector';
export const walletconnect = new WalletConnectConnector({
rpc: { 1: RPC_URLS[1], 4: RPC_URLS[4] },
infuraId: INFURA_TOKEN,
bridge: BRIDGE_URL,
qrcode: true,
pollingInterval: 15000,
});
Also, the versions of packages are as follows:
"@web3-react/core": "^6.0.9",
"@web3-react/walletconnect-connector": "^6.2.0",
When I use the activate
function from useWeb3React()
as explained in below code:
const { connector, activate, active, account } = useWeb3React();
activate(walletconnect, undefined, true)
.catch((error) => {
if (error instanceof UnsupportedChainIdError) {
activate(walletconnect)
} else {
console.log('Pending Error Occured')
}
})
It was able to generate QR Code, also I was able to successfully scan through MetaMask app on my Mobile Phone and on the mobile app it shows successfully connected.
Though, on the console logs of the Web App it shows a warning saying
Warning: Suppressed stale connector activation [object Object]
Thus, It fails to receive address inside the account
variable.
Important Note: I'm using the similar code with InjectedConnector
and it is working perfectly fine for MetaMask.
Though the above problem also appears with other wallets. These are the wallets I am facing the problem with:
- WalletConnect
- WalletLink (Coinbase Wallet)
- Portis
I've been trying to integrate WalletConnect by following this documentation of web3-react.
The configuration that I'm using for the connector is as follows:
import { WalletConnectConnector } from '@web3-react/walletconnect-connector';
export const walletconnect = new WalletConnectConnector({
rpc: { 1: RPC_URLS[1], 4: RPC_URLS[4] },
infuraId: INFURA_TOKEN,
bridge: BRIDGE_URL,
qrcode: true,
pollingInterval: 15000,
});
Also, the versions of packages are as follows:
"@web3-react/core": "^6.0.9",
"@web3-react/walletconnect-connector": "^6.2.0",
When I use the activate
function from useWeb3React()
as explained in below code:
const { connector, activate, active, account } = useWeb3React();
activate(walletconnect, undefined, true)
.catch((error) => {
if (error instanceof UnsupportedChainIdError) {
activate(walletconnect)
} else {
console.log('Pending Error Occured')
}
})
It was able to generate QR Code, also I was able to successfully scan through MetaMask app on my Mobile Phone and on the mobile app it shows successfully connected.
Though, on the console logs of the Web App it shows a warning saying
Warning: Suppressed stale connector activation [object Object]
Thus, It fails to receive address inside the account
variable.
Important Note: I'm using the similar code with InjectedConnector
and it is working perfectly fine for MetaMask.
Though the above problem also appears with other wallets. These are the wallets I am facing the problem with:
- WalletConnect
- WalletLink (Coinbase Wallet)
- Portis
1 Answer
Reset to default 2I solved it in two ways:
Calling the activate function multiple times in subsequent lines
Setting a delay on calling the activate function, something like this
setTimeout(() => activate(...), 500)
I'm not sure about your code structure so I don't know to what extend this helps. But stale connector object issue is something that I have resolved using the above two methods.
本文标签: javascriptHow to integrate WalletConnect in your Dapp using web3reactStack Overflow
版权声明:本文标题:javascript - How to integrate WalletConnect in your Dapp using web3-react? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744293277a2599218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论