Javascript Libraries for create eos abi schema
initial abi def
const customTypes = {};
const abi = new ABI(customTypes);
create an ActionData
object
- struct the action data def
- value the action data
Run actionData.toBytes()
to get the action data in bytes
format
create a Schema
object
- struct the schema abi def
Run
schema.normalize(data)
to format data by abi def
import { ABI } from 'eos-abi';
const abi = new ABI();
const actionData = abi.createActionData({
account: "name",
memo: "string"
}, {
account: 'eosio',
memo: 'hello'
});
const schema = abi.createSchema({
account: 'name',
time: 'time',
key: 'public_key',
action: {
name: 'name',
data: 'bytes'
}
});
const data = schema.normalize({
account: 'eosio',
time: '2018-04-11 12:00',
key: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
action: {
name: 'eosio',
data: actionData.toBytes()
}
});
console.log(data);
The result is
{ account: 'eosio',
time: '2018-04-11T04:00:00',
key: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
action: {
name: 'eosio',
data: '000000005087a9020568656c6c6f'
}
}
- bytes
- int8
- int16
- int32
- int64
- name
- public_key
- string
- time
- uint8
- uint16
- uint32
- uint64
- uint128