OneKey Docs
  • 👋GUIDE
    • Introduction
    • Web App Integration Developer
    • Hardware Integration Developer
    • External Contribution Guide
    • Common Terms
  • 🔮Connect To Software
    • Compatible with Metamask
      • detectEthereumProvider
    • Support Wallet Kit
      • Web3 Onboard
      • Rainbowkit
      • Aptos Wallet Adapter
      • Web3Modal
    • WebApp Connect OneKey
      • ETH
        • Provider API
        • RPC API
        • Accessing Accounts
        • Sending Transactions
        • Signing Data
      • BTC
        • Guide
        • API Reference
          • requestAccounts
          • getAccounts
          • getNetwork
          • switchNetwork
          • getPublicKey
          • getBalance
          • getInscriptions
          • sendBitcoin
          • sendInscription
          • signMessage
          • pushTx
          • signPsbt
          • signPsbts
          • pushPsbt
          • inscribeTransfer (Deprecated)
        • Event
      • Nostr
        • Guide
        • API Reference
          • getPublicKey
          • signEvent
          • signSchnorr
          • getRelays
          • nip04.encrypt
          • nip04.decrypt
        • Event
      • WebLN
        • Guide
        • API Reference
          • enable
          • getInfo
          • makeInvoice
          • sendPayment
          • signMessage
          • verifyMessage
          • lnurl
          • getBalance
        • Event
      • NEAR
        • Introduction
        • Integrating
          • Install the Provider SDK
          • Detecting the Provider
          • Establishing a Connection
          • Accessing Accounts
          • Detecting Provider Network
          • Watch Accounts & Network Status
          • Sending Transactions
            • Create Transaction
            • Sign and Send Transaction
            • Signing Transaction
          • Signing Messages
          • RPC API Calling
          • Debug Logging
          • Migrate from Near Web Wallet
        • Reference
          • API Reference
          • Trouble Shooting
        • Resources
          • Example & Demo
          • FAQ
      • SOLANA
        • Detecting the Provider
        • Establishing a Connection
        • Sending a Transaction
        • Signing a Message
    • Using WalletConnect
      • ETH
      • APTOS
        • Wallet Connect API
  • 📟Connect to Hardware
    • Hardware SDK
      • Started
      • Install SDK
      • Config Event
      • Common Params
      • Path Params
      • Error Code
      • API Reference
        • Basic API
          • Init SDK
          • Search Devices
          • Get Features
          • Get Passphrase State
          • Cancel Request
          • Response UI Event
        • Device API
          • deviceSupportFeatures
          • checkBridgeStatus
          • checkTransportRelease
          • checkFirmwareRelease
          • checkBLEFirmwareRelease
          • deviceChangePin
          • deviceReset
          • deviceSettings
          • deviceUpdateReboot
          • deviceVerify
          • deviceWipe
          • firmwareUpdate
        • Bitcoin & Bitcoin forks
          • btcGetAddress
          • btcGetPublicKey
          • btcSignMessage
          • btcSignTransaction
          • btcVerifyMessage
        • Ethereum & EVM
          • evmGetPublicKey
          • evmGetAddress
          • evmSignTransaction
          • evmSignTypedData
          • evmSignMessage
          • evmVerifyMessage
        • Algorand
          • algoGetAddress
          • algoSignTransaction
        • Aptos
          • aptosGetAddress
          • aptosGetPublicKey
          • aptosSignMessage
          • aptosSignTransaction
        • Alephium
          • alephiumGetAddress
          • alephiumSignMessage
          • alephiumSignTransaction
        • Cardano
          • cardanoGetAddress
          • cardanoGetPublicKey
          • cardanoSignMessage
          • cardanoSignTransaction
        • Conflux
          • confluxGetAddress
          • confluxSignMessage
          • confluxSignMessageCIP23
          • confluxSignTransaction
        • Cosmos
          • cosmosGetAddress
          • cosmosGetPublicKey
          • cosmosSignTransaction
        • Dynex
          • dnxGetAddress
          • dnxSignTransaction
        • FileCoin
          • filecoinGetAddress
          • filecoinSignTransaction
        • Kaspa
          • kaspaGetAddress
          • kaspaSignTransaction
        • Near
          • nearGetAddress
          • nearSignTransaction
        • Nervos
          • nervosGetAddress
          • nervosSignTransaction
        • Nostr
          • nostrGetPublicKey
          • nostrSignEvent
          • nostrSignSchnorr
          • nostrEncryptMessage
          • nostrDecryptMessage
        • NEM
          • nemGetAddress
          • nemSignTransaction
        • Nexa
          • nexaGetAddress
          • nexaSignTransaction
        • Polkadot
          • polkadotGetAddress
          • polkadotSignTransaction
        • Ripple
          • xrpGetAddress
          • xrpSignTransaction
        • Scdo
          • scdoGetAddress
          • scdoSignMessage
          • scdoSignTransaction
        • Solana
          • solGetAddress
          • solSignTransaction
        • Starcoin
          • startcoinGetAddress
          • starcoinGetPublicKey
          • starcoinSignMessage
          • starcoinSignTransaction
          • starcoinVerifyMessage
        • Stellar
          • stellarGetAddress
          • stellarSignTransaction
        • Sui
          • suiGetAddress
          • suiGetPublicKey
          • suiSignMessage
          • suiSignTransaction
        • Tron
          • tronGetAddress
          • tronSignMessage
          • tronSignTransaction
        • Ton
          • tonGetAddress
          • tonSignMessage
          • tonSignProof
      • Advanced
        • Passphrase
        • Common SDK Guide
        • Low-level transport plugin
        • OneKey Message Protocol
      • Tutorial: Get started with OneKey
    • Air Gap SDK
      • Started
      • Tutorial: Wallet Integration
      • API Reference
        • Basic API
          • CryptoHDkey
          • CryptoCoinInfo
          • CryptoKeypath
        • Ethereum & EVM
          • EthSignRequest
          • EthSignature
  • ⛳Best Practice
    • Registering Your Contract's Method Names
    • Registering Tokens with Users
    • Defining Your App's Icon
    • Migration from MetaMask
  • 🎨Logo Assets
  • 🧙Support
  • 🕹️Trouble Shooting
  • ❤️Contribute
Powered by GitBook
On this page
  • Basic Usage
  • Methods
  • account
  • network
  • getChainId
  • signAndSubmitTransaction
  • signMessage
  • Event
  • Example

Was this helpful?

Edit on GitHub
  1. Connect To Software
  2. Using WalletConnect
  3. APTOS

Wallet Connect API

PreviousAPTOSNextHardware SDK

Last updated 2 years ago

Was this helpful?

Basic Usage

First check out WalletConnect 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

Methods

The following methods are all custom methods outside of WalletConnect, so you need to use 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.

Request

walletConnector.sendCustomRequest({ method: "account" })

Response

{
    "publicKey": "0xf7768b9884081c0a781b3bff6dd896acfdc2728a29fbe9b711ee4f39040d5afb",
    "address":"0xc046a096af4602ef60766ffd88033d178e5658cf31827049f3709c62a28a2680"
} 

network

Request

walletConnector.sendCustomRequest({ method: "network" })

Response

"Mainnet" # Or "Testnet"

getChainId

Request

walletConnector.sendCustomRequest({ method: "getChainId" })

Response

{ "chainId": 1 } 

signAndSubmitTransaction

const transaction = {
    arguments: [address, '10000'],
    function: '0x1::coin::transfer',
    type: 'entry_function_payload',
    type_arguments: ['0x1::aptos_coin::AptosCoin'],
};

walletConnector.sendCustomRequest({ 
    method: "signAndSubmitTransaction",
    params: [transaction]
}})

Response

{
    "hash": "0xdcf7548f1c8679d1607ea7e5102cc75f19af355058c0ffe4ef9e5703f133adc7",
    "sender": "0xd7663c457cfb8516f400454c4d31b43a0161596d5109e3b789848f371fbaee8d",
    "sequence_number": "16",
    "max_gas_amount": "890",
    "gas_unit_price": "100",
    "expiration_timestamp_secs": "1666586889",
    "payload": {
        "function": "0x1::coin::transfer",
        "type_arguments": [
        "0x1::aptos_coin::AptosCoin"
        ],
        "arguments": [
        "0xd7663c457cfb8516f400454c4d31b43a0161596d5109e3b789848f371fbaee8d",
        "100000"
        ],
        "type": "entry_function_payload"
    },
    "signature": {
        "public_key": "0xc35b5938c4d1524641e5732430bd101a22dc9551d8e554366aa61e07f497a4fb",
        "signature": "0x901a2c404e7d6f6427228bc0f1498217ac2429c198583f2a693390d5d28f5cc6313505886accb8673eb1e80e9c85ca91adc13dc32eb7542a50c3318fc3e6f906",
        "type": "ed25519_signature"    
    },
}

signMessage

Request

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
}

Event

Todo

Example

Request Example Transaction, following an

follow

🔮
documentation
documentation
sendCustomRequest
EntryFunctionPayload
PendingTransaction
Onekey Aptos WalletConnect Example