worldwide-asset-exchange / waxjs

Javascript API for integration with the WAX Cloud Wallet.
MIT License
126 stars 103 forks source link

Wax account log in #169

Closed lumoverix closed 7 months ago

lumoverix commented 8 months ago

No where in any examples do I see usage of the password or private key, how does login supposed to work if there is never passed the password or private key?

niksad8 commented 8 months ago

waxjs is an interface between the dapp and user, there is no username and password here cause they user will login to their account using the waxjs interface in the browser. when the user logs in the waxjs library will get the user accounts and public keys, after which you can execute transactions on behalf of the user, if you need to use private keys and so on you will need to use the eosjs and waxjs is not necessary.

const { Api, JsonRpc, RpcError, Serialize } = require('eosjs');
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); // EOSJS v2
const fetch = require('node-fetch'); // or any other HTTP request library
const { TextEncoder, TextDecoder } = require('util');

const rpc = new JsonRpc('https://your-eos-rpc-endpoint.com', { fetch });
const signatureProvider = new JsSignatureProvider(['YOUR_PRIVATE_KEY']);
const api = new Api({ rpc, signatureProvider, textEncoder: new TextEncoder(), textDecoder: new TextDecoder() });
lumoverix commented 8 months ago

Thanks for that reply, very much.

Does that interface with a fully synced https://github.com/worldwide-asset-exchange/wax-node ?

niksad8 commented 8 months ago

yes it does and remember that wax-node is server node for waxjs if you plan to setup your own node. waxjs is just like an oauth layer for dapps and eosjs is the blockchain interface that lets you interface with the wax block chain. generally frontend apps will use waxjs to authenticate the user and execute smart contract actions on behalf on the user. eosjs is a layer below that, in this context most of the time eosjs is usually used on the server side. eg : you want to sign a transaction with your private key for your smart contract.