Skip to content

Integration Guide: Linking Wallet Connect with WAX Blockchain

This guide walks you through the integration of Wallet Connect and WAX Blockchain, shedding light on the essential RPC interfaces and their intricacies. Whether you're a seasoned developer or a novice in the world of blockchain, this comprehensive overview will navigate you through the processes of setting up, signing, and pushing transactions seamlessly.

I. Setting up Wallet Connect < > WAX Blockchain

II. Login Session with WalletConnect

Utilize a socket-based login session to establish a connection between a decentralized application (Dapp) and WalletConnect.

Parameters

requiredNamespaces {
chains?: string[];
methods: string[];
events: string[];
}
chain: list chain id support(Currently, only support one wax chain)
Method: list support method
Events: list support events
pairingTopic string Pairing topic id

Example

json
requiredNamespaces: {
  wax: {
    methods: [
      "wax_sign_transaction",
      "wax_sign_message",
      "wax_push_transaction",
      "wax_sign_push_transaction",
      "wax_sign_pushed_transaction",
      "wax_request_account",
      "wax_get_available_keys",
      "wax_get_required_keys"
    ],
      chains: [
        "antelope:1064487b3cd1a897ce03ae5b6a865651"
      ],
        events: []
  }
},
pairingTopic: '4738621948defd3bf860cd2a235f1d998ed7e136fd3c82f19f3cd6ce7f8abcc8'

Response:

If the request is rejected, a 4001 error will be returned.

Example

json
{
    "message": "User rejected methods.",
    "code": 5002
}

If the request is accepted, a WAX account string is returned.

Example

json
{
  topic: "6907a4234c1f1cd21e668514997995c614bfe5c5cf7b87b4840e0135b77205aa",
  relay: {
    protocol: "irn"
  },
  expiry: 1692803184,
  namespaces: {
    wax: {
      accounts: [
        "antelope:1064487b3cd1a897ce03ae5b6a865651:qs.wam@active"
      ],
      methods: [
        "wax_sign_transaction",
        "wax_sign_message",
        "wax_push_transaction",
        "wax_sign_push_transaction",
        "wax_sign_pushed_transaction",
        "wax_request_account",
        "wax_get_available_keys",
        "wax_get_required_keys"
      ],
      events: []
    }
  },
  acknowledged: true,
  pairingTopic: "829b57ad756e90851f73880abec4495b1ae76ba25e4f1dd72dfd802d25088b66",
  requiredNamespaces: {
    wax: {
      methods: [
        "wax_sign_transaction",
        "wax_sign_message",
        "wax_push_transaction",
        "wax_sign_push_transaction",
        "wax_sign_pushed_transaction",
        "wax_request_account",
        "wax_get_available_keys",
        "wax_get_required_keys"
      ],
      chains: [
        "antelope:1064487b3cd1a897ce03ae5b6a865651"
      ],
      events: []
    }
  },
  optionalNamespaces: {},
  controller: "eb288c78fa542b94163d511d8742ae46ce2809d7512aa58b50965cea95fbe643",
  self: {
    publicKey: "18a1f6da1dfa6f4147c017d22a62ea86232ed90c3742324ae29cc8270b756373",
    metadata: {
      description: "React App for WalletConnect",
      url: "http://localhost:3000",
      icons: [
        "https://avatars.githubusercontent.com/u/37784886"
      ],
      name: "React App"
    }
  },
  peer: {
    publicKey: "eb288c78fa542b94163d511d8742ae46ce2809d7512aa58b50965cea95fbe643",
    metadata: {
      name: "Cloud Wallet",
      description: "Cloud Wallet is your all-inclusive custody wallet to access WAX blockchain and other web3 applications. Trusted by more than 13 millions of users worldwide.",
      url: "https://www.mycloudwallet.com/",
      icons: [
        "https://www.mycloudwallet.com/logo192.png"
      ]
    }
  }
}

II. RPC interface

RPC Specs


TIP

To provide context and information about the requesting DApp, Wallet can retrieve that data from the login session.

name string Name of Dapp
description string Description of Dapp
icons string[] Array url of icon
url string Url of Dapp
chains string[] Array of the requested login chainIds

Example

json
{
  name: "Atomic Assets",
  description: "NFT Marketplace on WAX",
  url: "https://atomicassets.io",
  icons: [
    "https://avatars.githubusercontent.com/u/37784886"
  ],
  chains: [
    "antelope:1064487b3cd1a897ce03ae5b6a865651"
  ]
}

wax_get_available_keys

Description

Get public keys associated with the account, corresponding to the private keys held by the wallet.

Parameters

account string Public keys associated with the account

Return

public_keys Array of strings (PublicKey) Public keys associated with the private keys that the wallet holds

Example

json
Request:
{
    account: 'qs.wam',
}


Return:
{
    public_keys: [
        "EOS5wMVefW4H11BbhQ7uqtojfrFG9tsXkXuiTNkBvzFhCbysQjjkp",
        "EOS6wigZhV8BEEdFLebPiiNGNKyPw8X3RqxLvDaoYAP7z4SkLKbYi"
    ]
}

wax_sign_message

Description

Sign a message with the private keys specified via their public keys.

Parameters

required_keys Array of strings (PublicKey) the public key of the corresponding private key to sign the transaction with
message
(Optional)
Array of any Message

Return

signatures Array of strings (PublicKey) (Signature) Signature

Example

json
Request:
{
    public_keys: [
        "EOS5wMVefW4H11BbhQ7uqtojfrFG9tsXkXuiTNkBvzFhCbysQjjkp",
        "EOS6wigZhV8BEEdFLebPiiNGNKyPw8X3RqxLvDaoYAP7z4SkLKbYi"
    ],
    message: [
            {
              account: "eosio.token",
              name: "transfer",
              data: {
                from: account,
                to: "ac.wam",
                quantity: "0.12300001 WAX",
                memo: "",
              },
              authorization: [
                {
                  actor: account,
                  permission: "active",
                },
              ],
            },
            {
              account: "eosio.token",
              name: "transfer",
              data: {
                from: account,
                to: "ac.wam",
                quantity: "0.00000001 WAX",
                memo: "",
              },
              authorization: [
                {
                  actor: account,
                  permission: "active",
                },
              ],
            },
          ]

}


Return:
{
    "account": "qs.wam",
    "public_keys": [
        "EOS5wMVefW4H11BbhQ7uqtojfrFG9tsXkXuiTNkBvzFhCbysQjjkp",
        "EOS6wigZhV8BEEdFLebPiiNGNKyPw8X3RqxLvDaoYAP7z4SkLKbYi"
    ]
}

wax_sign_transaction

Description

Sign a transaction with the private keys specified via their public keys.

Parameters

required_keys Array of strings (PublicKey) the public key of the corresponding private key to sign the transaction with
serialized_transaction Array of Uint8 Transaction to sign
serialized_context_free_data(optional) Array of Uint8 Context-free data to sign
transaction (optional) Object(Transaction)
{
expiration?: string;

ref_block_num?: number;

ref_block_prefix?: number;

max_net_usage_words?: number;

max_cpu_usage_ms?: number;

delay_sec?: number;

context_free_actions?: Action[];

context_free_data?: Uint8Array[];

actions: Action[];

transaction_extensions?: [number, string][];

resource_payer?: ResourcePayer;
}

Return

signatures Array of strings (PublicKey) (Signature) Signature
serializedTransaction Array of Uint8 Transaction to sign
serializedContextFreeData
(Optional)
Array of Uint8 Context-free data to sign

Example

json
Request:
{
  required_keys: [
    "EOS5wMVefW4H11BbhQ7uqtojfrFG9tsXkXuiTNkBvzFhCbysQjjkp",
    "EOS6wigZhV8BEEdFLebPiiNGNKyPw8X3RqxLvDaoYAP7z4SkLKbYi"
  ],
  serialized_transaction: {
    0: 222,
    1: 159,
    146: 0,
    147: 0,
    148: 0,
    149: 0
  },
  transaction: {
    delay_sec: 0,
    max_cpu_usage_ms: 0,
    actions: [
      {
        account: "eosio.token",
        name: "transfer",
        data: {
          from: "qs.wam",
          to: "ac.wam",
          quantity: "0.00000001 WAX",
          memo: ""
        },
        authorization: [
          {
            actor: "qs.wam",
            permission: "active"
          }
        ]
      }
    ]
  }
}



Return:
{
    "signatures": [
        "SIG_K1_K8ZLhxdoMRGm9sAGWi4cqyH1kDcbJwxrcSHeW536W48rfZKsgdpNo7ucmUPUL5ALaC7pN9R7HgtbSeepjBu2AvodW7UuMj",
        "SIG_K1_K8EY9r7JHbnzNFTAD4A6LmDkPE1AaEjRNJykYVxU5DB2XUNjRkceAVro2VCcXYesDUgi159xG18QN4goBtTZLc9WtKZs5d"
    ],
    "serializedTransaction": [
        59,
        165,
        ...,
        0,
        0,
        0,
        8,
        87,
        65,
        88,
        0,
        0,
        0,
        0,
        0,
        0
    ],
    "estimatorWorking": true,
    "ram": 0,
    "cpu": 1194,
    "net": 27,
    "waxFee": 0,
    "ramFee": 0
}

wax_sign_push_transaction(Optional)

Description

Sign and push a transaction with the private keys specified via their public keys.

Parameters

required_keys Array of strings (PublicKey) the public key of the corresponding private key to sign the transaction with
serialized_transaction Array of Uint8 Transaction to sign
serialized_context_free_data Array of Uint8 Context-free data to sign
transaction (optional) Object(Transaction)
{
expiration?: string;

ref_block_num?: number;

ref_block_prefix?: number;

max_net_usage_words?: number;

max_cpu_usage_ms?: number;

delay_sec?: number;

context_free_actions?: Action[];

context_free_data?: Uint8Array[];

actions: Action[];

transaction_extensions?: [number, string][];

resource_payer?: ResourcePayer;
}

Return

signatures Array of strings (PublicKey) (Signature) Signature
serialized_transaction Array of Uint8 Transaction to sign
serialized_context_free_data Array of Uint8 Context-free data to sign

Example

json
Request:
{

}


Return:
{

}

wax_push_transaction(optional)

https://developers.eos.io/manuals/eos/v2.1/nodeos/plugins/chain_api_plugin/api-reference/index/#operation/push_transactions

This method expects a transaction in JSON format and will attempt to apply it to the blockchain.

Parameters

signatures Array of strings (Signature) array of signatures required to authorize transaction
compression boolean Compression used, usually false
packed_context_free_data string json to hex
packed_trx string Transaction object json to hex