Use WaxJS

The WaxJS library exposes three primary components:

  • wax.userAccount. This is the WAX Account user name, returned when you make a call to wax.login().
  • wax.api. Use this to execute standard eosjs transactions.
  • wax.rpc. Use this to make API calls to the WAX Blockchain. Refer to WAX RPC API for more information.

To use WaxJS:

  1. Import the Library

    React style apps using npm or yarn can import the library via:

    import * as waxjs from "@waxio/waxjs/dist";

    You can also download and save WaxJS from GitHub and include the file on a web page:

    <script src='waxjs.js'></script>
  2. Instantiate the WaxJS Object

    Instantiate the waxjs object with the RPC server you wish to connect to (e.g., - recommended).

    const wax = new waxjs.WaxJS('');
  3. Log in a User

    To get a user’s WAX Blockchain Account name, call the wax.login() function.

    const userAccount = await wax.login();

    This function opens WAX Cloud Wallet in a new browser window. Users are prompted that your dApp would like to “Know your WAX Account Name.” Once they click Approve, they’re redirected back to your dApp.

    A successful login returns the userAccount (e.g., jq3ao.wam), and you can also access this property by calling wax.userAccount.

  4. Send a Transaction

    Now that you have a user’s WAX Account name, you can use the wax.api object to build your transaction.

    Note: The wax.api method is not initialized until you log in your user.
    const result = await wax.api.transact({
      actions: [{
        account: 'eosio.token',
        name: 'transfer',
        authorization: [{
          actor: wax.userAccount,
          permission: 'active',
        data: {
          from: wax.userAccount,
          to: 'eosio',
          quantity: '0.00000001 WAX',
          memo: '',
    }, {
      blocksBehind: 3,
      expireSeconds: 1200,
    Tip: The wax.api method is an instance of the eosjs object, and provides the same functionality. Refer to the eosjs docs for more information.

    The wax.api.transact() function launches WAX Cloud Wallet in a new browser window. On this screen, users can review the transaction details and Approve or Deny the transaction. Once users click Approve, the transaction is signed on the WAX Blockchain and users are returned to your dApp.

What's Next