@stefanzoid/sc-decoder
v3.1.0
Published
Smart Contracts Decoder
Downloads
5
Maintainers
Readme
sc-decoder
Example
const { decode } = require('@stefanzoid/sc-decoder')
const scAddress = "erd1qqqqqqqqqqqqqpgqd06v3r6r94hgyarcar27hkexamh50u283tpqlyspkr";
const funcName = "getStaking";
const struct = {
"pool_id": "Address",
"staked_amount": "BigUint",
"timestamp": "u64",
"months": "u16",
"is_pool": "bool",
"address": "Address"
};
const type = "VecMapper<struct>";
const args = ["df1262d8e96f1f24ffff170e6eb5be6b0fd9fa7fb1dc53dc71b2822c42fc7ed4"];
const result = await decode(scAddress, funcName, struct, type, args);
Use cases:
NOTE Please adapt to the example above!
Single value || SingleValueMapper:
{
"scAddress": "erd1qqqqqqqqqqqqqpgqd06v3r6r94hgyarcar27hkexamh50u283tpqlyspkr",
"funcName": "getPoolLimit",
"struct": {},
"type": "u32",
"args": []
}
If single value === struct:
{
"scAddress": "erd1qqqqqqqqqqqqqpgqd06v3r6r94hgyarcar27hkexamh50u283tpqlyspkr",
"funcName": "getPool",
"struct": {
"id": "Address",
"owner": "Address",
"total_staked": "BigUint",
"zoidsters": "u32",
"name": "String",
"status": "u8"
},
"type": "struct",
"args": [
"df1262d8e96f1f24ffff170e6eb5be6b0fd9fa7fb1dc53dc71b2822c42fc7ed4"
]
}
VecMapper
{
"scAddress": "erd1qqqqqqqqqqqqqpgqd06v3r6r94hgyarcar27hkexamh50u283tpqlyspkr",
"funcName": "getStaking",
"struct": {
"pool_id": "Address",
"staked_amount": "BidUint",
"timestamp": "u64",
"months": "u16",
"is_pool": "bool",
"address": "Address"
},
"type": "VecMapper<struct>",
"args": [
"df1262d8e96f1f24ffff170e6eb5be6b0fd9fa7fb1dc53dc71b2822c42fc7ed4"
]
}
MapMapper
{
"scAddress": "erd1qqqqqqqqqqqqqpgqd06v3r6r94hgyarcar27hkexamh50u283tpqlyspkr",
"funcName": "getPools",
"struct": {
"id": "Address",
"owner": "Address",
"total_staked": "BigUint",
"zoidsters": "u32",
"name": "String",
"status": "u8"
},
"type": "MapMapper<Address, struct>",
"args": []
}