Skip to content

worldwide-asset-exchange/wax-json-websocket-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

WAX JSON Websocket API (As Used with WalletConnect)

  1. Overview

WalletConnect-WAX Interaction Layout

  1. Login session

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:

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'


Return

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

Example:

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

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

Example

{
  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 application. Trusted by more than 13 millions of users worldwide.",
      url: "https://www.mycloudwallet.com/",
      icons: [
        "https://www.mycloudwallet.com/logo192.png"
      ]
    }
  }
}

  1. RPC specs

Note: 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:

{

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

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

Platforms: Desktop, Mobile

Parameters

account string Account and permission

Return

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

Example

// Request
{
   acount:"mywaxaccount@active",
}

// Result
{
   "public_keys":[
      "EOS7y2xNA5TsoAXTeGJgfDMhVGPMCxJ9vuM71H9TSe48CoECKsXej",
      "EOS8UhZSLGoiUSifugc4x2LrLbKW6GwKKNzJbxtZBBChqcKbfV18G"
   ]
}

wax_sign_transaction

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

Refer this to implement the sign transaction

(Currently, WCW is only support sign with active permission)

Platforms: Desktop, Mobile

Parameters: application/json

required_keys Array of strings (PublicKey) Public keys associated with the private keys needed to sign the transaction
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: application/json

signatures Array of strings (Signature) array of signatures required to authorize transaction
serialized_transaction Array of Uint8 Transaction to sign
serialized_context_free_data(optional) Array of Uint8 Context-free data to sign

Example:

// Request
{
  required_keys: [
    "EOS5wMVefW4H11BbhQ7uqtojfrFG9tsXkXuiTNkBvzFhCbysQjjkp",
    "EOS6wigZhV8BEEdFLebPiiNGNKyPw8X3RqxLvDaoYAP7z4SkLKbYi"
  ],
  serialized_transaction: {
      1,
      2,
      3,
      4
  },
  transaction: {
    delay_sec: 0,
    max_cpu_usage_ms: 0,
    actions: [
      {
        account: "eosio.token",
        name: "transfer",
        data: {
          from: "qs.wam",
          to: "ac.wam",
          quantity: "0.12300001 WAX",
          memo: ""
        },
        authorization: [
          {
            actor: "qs.wam",
            permission: "active"
          }
        ]
      },
      {
        account: "eosio.token",
        name: "transfer",
        data: {
          from: "qs.wam",
          to: "ac.wam",
          quantity: "0.00000001 WAX",
          memo: ""
        },
        authorization: [
          {
            actor: "qs.wam",
            permission: "active"
          }
        ]
      }
    ]
  }
}


// Result
{
   "signatures":[
      "SIG_K1_abcdef..."
   ],
   "serialized_transaction":[
      1,
      2,
      3,
      4
   ],
   "serialized_context_free_data":[
      5,
      6,
      7,
      8
   ]
}

wax_sign_message

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

(Currently, WCW is only support sign with active permission)

Platforms: Desktop, Mobile

Parameters

message any[] Array of message need to sign
required_keys Array of strings (PublicKey) the public key of the corresponding private key to sign the transaction with

Return: application/json

signature Array of strings (PublicKey) (Signature)

Example

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

}

// Result
{
   "signature":"SIG_K1_KAeg7fP2fQzMSQKg8XdTAd2rDFEkJosq1KeTtvB8shzbn532F5UPWy62io2Wpud3Zj3XXuckcmYNV5qPR8tqAkns7m83WK"

wax_get_required_keys(optional)

Platforms: Desktop, Mobile

Refer: https://developers.eos.io/manuals/eos/v2.2/nodeos/plugins/chain_api_plugin/api-reference/index#operation/get_required_keys

Returns the required keys needed to sign a transaction.

Parameters

transaction object(Transaction) \ {

"expiration":"string",

"ref_block_num":0,

"ref_block_prefix":0,

"max_net_usage_words":"string",

"max_cpu_usage_ms":"string",

"delay_sec":0,

"context_free_actions":[

],

"actions":[

],

"transaction_extensions":[

]

}

}

available_keys Array of strings (PublicKey)

Return

public_keys Array of strings (PublicKey) An array of public key strings associated with the private keys that are required to sign the transaction.

Example:

// Request
{
   "transaction":{
      "expiration":"string",
      "ref_block_num":0,
      "ref_block_prefix":0,
      "max_net_usage_words":"string",
      "max_cpu_usage_ms":"string",
      "delay_sec":0,
      "context_free_actions":[

      ],
      "actions":[

      ],
      "transaction_extensions":[

      ]
   },
   "available_keys":[
      "EOS7y2xNA5TsoAXTeGJgfDMhVGPMCxJ9vuM71H9TSe48CoECKsXej",
      "EOS8UhZSLGoiUSifugc4x2LrLbKW6GwKKNzJbxtZBBChqcKbfV18G"
   ]
}

// Result
{
   "public_keys":[
      "EOS7y2xNA5TsoAXTeGJgfDMhVGPMCxJ9vuM71H9TSe48CoECKsXej",
   ]
}

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.

Platforms: Desktop, Mobile

Parameters: application/json

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

Return: application/json

Example:


About

WAX JSON Websocket API for WalletConnect

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published