Javascript SDK for EOS LIVE Dapp
- Npm
import live from 'live-eosjs/browser';
console.log(live.isConnect());
- Html script tag.
<html>
<head>
<meta charset="utf-8">
<script src="./node_modules/live-eosjs/dist/browser.umd.js"></script>
<script>
var live = window.WebViewInvoke;
console.log(live.isConnect());
</script>
</head>
</html>
Firstly, bind some functions which exposed from EOS LIVE.
const EosTokenTransfer = live.bind('eosTokenTransfer');
const PushEosAction = live.bind('pushEosAction');
Now, we can use them.
let result = await EosTokenTransfer();
// 'return result'
let result = await PushEosAction();
// 'return result'
In addition, you can use them without definition too.
let result = await live.fn.eosTokenTransfer();
// 'return result'
let result = await live.fn.pushEosAction();
// 'return result'
live.eosTokenTransfer(params);
params
- Object
:
from
:String
to
:String
amount
:String | Number
symbol
:String
precision
:Number | String
contract
:String
memo
:String
- (optional)
Object
:
status
:Number
data
:Object
transactionId
:Stirng
message
:String
let result = await live.eosTokenTransfer({
from: 'superoneioaa',
to: 'superoneiobb',
amount: '0.0100',
symbol: 'EOS',
precision: 4,
contract: 'eosio.token',
memo: 'test'
});
> {
status: 200,
data: { transactionId: '' },
message: 'success'
}
live.getCurrentWallet()
Object
:
status
:Number
data
:Object
name
:String
message
:String
let result = await live.getCurrentWallet();
> {
status: 200,,
data: {
name: 'superoneioaa',
},
message: 'success'
}
live.getEosBalance(params);
params
- Object
:
account
:String
contract
:String
symbol
:String
Object
:
status
:Number
data
:Object
symbol
:String
balance
:String
contract
:String
account
:String
message
:String
let result = await live.getEosBalance({
account: 'superoneioaa',
contract: 'eosio.token',
symbol: 'EOS'
});
> {
status: 200,
data: { "symbol": "EOS", "balance": "["100 EOS"]", "contract": "eosio.token", "account": "superoneioaa" },
message: 'success'
}