more wallet dapp js sdk
import mw from 'morewallet.js';
const dappName = "dappdemo";
const client = mw.getClient(dappName);
//Get APP Version Number
client.getAppVersion().then(version => {
console.log(version);
}).catch(error => {
console.error(error);
});
//Current Account Information
client.getAccount();
//If Open in Wallet App
client.openInApp();
//Check If Can Execute A Cretain Action
client.checkAction("eosio.token", "transfer");
//Submit Action
const buyramData = {
payer: "demouser1111",
receiver: "demouser1111",
quantity: "10.0000 EOS"
};
const authorization = [{
actor: "demouser1111",
permission: "active"
}];
client.pushAction("eosio", "buyram", authorization, buyramData);
//Submit Action In Batch
const actions = [{
account: "eosio",
name: "buyram",
authorization: [{
actor: "demouser1111",
permission: "active"
}],
data: {
payer: "demouser1111",
receiver: "demouser1111",
quant: "10.0000 EOS"
}
}, {
account: "eosio",
name: "delegatebw",
authorization: [{
actor: "demouser1111",
permission: "active"
}],
data: {
from: "demouser1111",
receiver: "demouser1111",
stake_net_quantity: "10.0000 EOS",
stake_cpu_quantity: "5.0000 EOS",
transfer: false
}
}];
client.pushActions(actions);
//Transfer
client.transfer("eosio.token", "demouser1111", "100.0000 EOS", "hi");
//Get Balance
client.getCurrencyBalance("eosio.token", "EOS");
//Data Table
client.getTableRows({
code: "eosio",
scope: "eosio",
table: "global"
});
//Use Private Key signed Text
client.signText("text");
- Introduce script to page:
<script src="https://cdn.more.top/morewallet/1.0.5/morewallet.js.min.js"></script>
- Use
<script>
var dappName = "dappdemo"; //dapp name, shoud be the name field filled in wallet APP
var client = MOREWALLET.getClient(dappName);
client.getCurrencyBalance("eosio.token", "EOS");
</script>
Parameter
- account - the one want to check, no transfer means check current account
Check Account Information
Return Value
- account_name - String account name
- core_liquid_balance - String eos balance
- ram_quota - Integer ram
- net_weight - Integer bandwidth
- cpu_weight - Integer CPU
- permissions - Array authority information
- total_resources - Object resources information
- voter_info - Object voting information
Example
// async/await
const accountInfo = await client.getAccount();
// Promise
client.getAccount().then(accountInfo => {
console.log(accountInfo);
}).catch(e => {
console.error(e);
});
If Open in Wallet APP
Return Value
- res - Boolean
Example
// async/await
const inApp = await client.openInApp()
// Promise
client.openInApp().then(inApp => {
if (!inApp) {
console.log("open in morewallet")
}
})
Get APP Version Number
Return Value
- version - String
Check If Have Action Authority
Parameter
- contract - contract account
- action - action name
Return Value
- res - Boolean
Get Balance of Appointed Token
Parameter
- contract - contract account
- symbol - symbol name
Submit Action
Parameter
- contract - contract account
- action - action name
- authorization - authority array
- data - executive data
Submit Action in Batch
Parameter
- actions - action array
Transfer
Parameter
- contract - token contract
- to - receiver
- quantity - transfer amount
- memo - transfer memo
Get Data Table
Parameter
- params - check information,refer to
/chain/get_table_rows
Use Private Key Signed Text
Parameter
- text - signed text
Return Value
- signedText - String