First check out WalletConnect documentation for connecting wallet.
In addition to the WalletConnect URI, add a new parameter "network" to pass Aptos network information.
# Example
wc:00e46b69-d0cc-4b3e-b6a2-cee442f97188@1?bridge=https%3A%2F%2Fbridge.walletconnect.org&key=91303dedf64285cbbaf9120f6e9d160a5c8aa3deb67017a3874cd272323f48ae&network=aptos
If you have a OneKey wallet installed, it will connect to OneKey's current Aptos wallet.
For more questions about connecting with WalletConnect, please refer to the documentation
Methods
The following methods are all custom methods outside of WalletConnect, so you need to use sendCustomRequest to request them.
account
Tip
If you haven't connected your wallet or haven't given your consent, this method won't get any information.
export interface SignMessagePayload {
address?: boolean; // Should we include the address of the account in the message
application?: boolean; // Should we include the domain of the dapp
chainId?: boolean; // Should we include the current chain id the wallet is connected to
message: string; // The message to be signed and displayed to the user
nonce: string; // A nonce the dapp should generate
}
const signMessagePayload = {
address: false,
application: true,
chainId: true,
message: "This is a sample message",
nonce: 12345,
}
walletConnector.sendCustomRequest({
method: "signMessage",
params: [signMessagePayload]
}})
Response
export interface SignMessageResponse { address: string; application: string; chainId: number; fullMessage: string; // The message that was generated to sign message: string; // The message passed in by the user nonce: string, prefix: string,// Should always be APTOS signature: string; // The signed full message}{"message":"This is a sample message","nonce":12345,"prefix":"APTOS", "signature": "0x8995a00d31ff10f4d6d7cc4a8485fbe8aa04fb265b0f0629cf0184b9d37925e4bda001928a59f5c287f07dca9d9147b2b2ba004633cd4980ae0839fa1b34b70a",
"fullMessage":"APTOS\napplication: localhost:3000\nchainId: 1\nmessage: This is a sample message\nnonce: 12345","application":"http://localhost:3000","chainId":1}