Javascript API for integration with the WAX Cloud Wallet.
Check the WAX developer portal for full instructions
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 install @waxio/waxjs
yarn add @waxio/waxjs
React style apps using npm or yarn can import the library via:
import * as waxjs from "@waxio/waxjs/dist";
Instantiate the waxjs object with the RPC server you wish to connect to.
const wax = new waxjs.WaxJS('https://wax.greymass.com');
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...
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,
});
npm run docs
npm run test
npm run build
npm run build-web