connectCocoPay
Connect to CocoPay built-in wallet or external wallet for secure interaction between DApp and user wallet. CocoPay wallet supports mainstream EVM blockchains; external wallets support multi-platform access, including WalletConnect and TokenPocket.
Note:
Connection is considered complete only after a successful call
After successful connection, access wallet interfaces via the following global objects:
EVM series chains:
window.ethereum = window.parent.top.ethereumTRON chain:
window.tronWeb = window.parent.top.tronWeb
If using TokenPocket on RelayApp,
chainListmust include at least one available chain, otherwise the connection will fail
After successful connection, you can use web3.js and ethers.js to call on-chain contracts without additional configuration.
The following chain list represents the chain types currently supported by CocoPay, with more chains to be added continuously. If the required chain is not yet supported by CocoPay, use external wallet connection.
Ethereum
ETH
BNB Chain
BSC
Polygon
POLYGON
Avalanche-C
AVAXC
TRON
TRON
Arbitrum One
ARBITRUM
Poly Smart Chain
PSC
Viction
VIC
Request Parameters:
chainList
Array
Yes
Array of public chain abbreviations to connect (e.g., ["ETH", "BSC"]).
walletSupports
Array
No
Array of supported external wallets (e.g., ["WalletConnect", "TokenPocket"]). If not passed, defaults to connecting CocoPay; passing this adds wallet support.
Response Parameters:
chainType
String
Abbreviation of the chain for the successfully connected wallet.
account
String
Wallet address for the successful connection.
Call Example: