Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
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 demo 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 WAX RPC server you wish to connect to.
const wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com'
});
The library can also be instantiated 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({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: 'user1',
pubKeys: ['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({
rpcEndpoint: 'https://wax.greymass.com',
tryAutoLogin: false
});
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,
});
(userAccount: string, originalTx: any, augmentedTx: any) => void
. Where userAccount
is the account being signed for, originalTx
is the tx generated by your dapp, and augmentedTx
is the potentially bandwidth-managed altered tx you will receive from WAX. The default verifier does this for you, and you should check this to be confident that the verifier is sufficiently rigorous. OptionalSo long as waxjs is initialized with freeBandwidth = true
(this is the default), your dapp will take advantage of freebandwidth provided by WAX, up to 5ms of CPU and 5K words per user per 24 hours, and tentatively 50s per contract per 24 hrs.
Dapps that require more bandwidth will be able to register their own bandwidth via the bandwidth registration contract. More info on registering for extra bandwidth management can be found here.
So long as waxjs is initialized with feeFallback = true
(this is the default), Wallet automatically add action to transfer WAXP as fee for that transaction if user has enough balance. Transaction fee is calculated by formula:
waxFee = cpu_usage_us*CPU_FEE_RATIO + net_usage_words*NET_FEE_RATIO + FEE_CONSTANT;
By default CPU_FEE_RATIO=NET_FEE_RATIO=0.001, FEE_CONSTANT=0.01;
npm run docs
npm run serve
Note - run the demo app first (as above), and then run the tests suite:
npm run test
npm run build
npm run build-web
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.
FAQs
Javascript API for integration with the WAX Cloud Wallet.
The npm package waxjser receives a total of 1 weekly downloads. As such, waxjser popularity was classified as not popular.
We found that waxjser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.