1.7.1 • Published 1 month ago

@waxio/waxjs v1.7.1

Weekly downloads
290
License
MIT
Repository
-
Last release
1 month ago

waxjs

Javascript API for integration with the WAX Cloud Wallet.

Documentation

Check the WAX developer portal for full instructions

Installation

Browser

Grab the waxjs.js minified bundle in the dist-web folder of this repo, or build it yourself (see below). Check the example code to see how to use it.

NPM

npm install @waxio/waxjs

YARN

yarn add @waxio/waxjs

Usage

0. Import (for NPM and Yarn installations)

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

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

1. Instantiate

Instantiate the waxjs object with the RPC server you wish to connect to.

const wax = new waxjs.WaxJS('https://wax.greymass.com');

The library can also be instatiated with the user account and the public keys. Due to the library contains the user information, the login step can be avoided.

const wax = new waxjs.WaxJS('https://wax.greymass.com', 'user1', ['EOS7rC8jFvFrPYDqp3Nh3HdRfL79h11B1JhPEXy85enF5wwYzF3Hk']);

If you want to handle the auto-login on your side with the isAutoLoginAvailable function (to avoid waiting for the user to click a button), you can disable the auto-login function in the constructor (so it won't get called twice).

const wax = new waxjs.WaxJS('https://wax.greymass.com', null, null, false);

2. Login

Log your user in so as to access their wax account name for creating transactions.

const userAccount = await wax.login();

Successful login will return the userAccount. It will also be available as the userAccount member on the wax instance. You can now use the eosjs api member...

3. Use the eosjs Objects As Usual

Utilize the eosjs api and rpc members available on the wax instance. They are instances of the regular eosjs objects, Api, and JsonRpc, so you can do anything with them that eosjs already provides. Check the eosjs docs and repo for more info.

The api method will not be initialized until you login your user, and remember that the user's account name is available as the userAccount member on the wax instance.

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,
});

Development

Generate docs

npm run docs

Run tests

npm run test

Build lib

npm run build

Build for web

npm run build-web

Contributing

When making a pull request, please make sure to run npm run prettier to make sure your code is as formatted as possible. Also, make sure npm run lint runs without errors, since that is the final check before a new version is published to npm.

1.11.0-beta2

1 month ago

1.11.0-beta1

1 month ago

1.10.0-beta1

1 month ago

1.9.0-beta1

2 months ago

1.8.0-beta

3 months ago

1.7.1

3 months ago

1.7.0

5 months ago

1.6.1

8 months ago

1.6.0

8 months ago

1.6.0-beta

8 months ago

1.5.0

11 months ago

1.5.0-beta.1

11 months ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.4.0-beta-1

1 year ago

1.3.0-beta-3

1 year ago

1.3.0-beta-2

1 year ago

1.3.0-beta-1

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.2.0-beta.1

1 year ago

1.2.0-beta.2

1 year ago

1.1.0

2 years ago

1.1.1-beta-1

2 years ago

1.0.4-beta.5

2 years ago

1.0.4-beta.4

2 years ago

1.0.4-beta.3

2 years ago

1.0.4-beta.2

2 years ago

1.0.4-beta.1

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.1-beta-1

3 years ago

1.0.0-beta.1

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago