Created
February 23, 2019 07:59
-
-
Save CaliosD/42da8492bb73f8e377503c81d48dc308 to your computer and use it in GitHub Desktop.
Some snippets for self testing on local node of IOST blockchain. Feel free to use for testing, and feel free to star🌟if it's useful to you. 🚀
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IOST = require('iost') | |
const bs58 = require('bs58'); | |
const config = require("./config.dev.json") | |
/* config.dev.json like this: | |
{ | |
"rpcURL": "http://localhost:30001", | |
"privKey": "2yquS3ySrGWPEKywCPzX4RTJugqRh7kJSo5aehsLYPEWkUxBWA39oMrZ7ZxuM4fgyXYs2cPwh5n8aNNpH5x2VyK1" | |
} | |
*/ | |
// init iost sdk | |
let iost = new IOST.IOST({ // will use default setting if not set | |
gasPrice: 100, | |
gasLimit: 2000000, | |
delay: 0, | |
}, new IOST.HTTPProvider(config.rpcURL)); | |
// use RPC | |
const rpc = new IOST.RPC(new IOST.HTTPProvider(config.rpcURL)); | |
iost.setRPC(rpc); | |
// init admin account | |
const account = new IOST.Account("admin"); | |
const kp = new IOST.KeyPair(bs58.decode(config.privKey)); | |
account.addKeyPair(kp, "active"); | |
iost.setAccount(account); | |
const getContractStorage = async (contractId, key, field) => { | |
let result = await rpc.blockchain.getContractStorage(contractId, key, field, true); | |
return result["data"] | |
} | |
module.exports = { | |
getContractStorage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment