You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
As I was missing an example on how to use oo7-substrate with nodejs to call some runtime function, I hacked one up. Would be great if you could include this (and possibly more interesting examples)
constutil=require('util');varsubstrate=require('oo7-substrate');//window=global;//substrate.setNodeUri(['wss://substrate-rpc.parity.io/']); // charred cherry//substrate.setNodeUri(['wss://poc3-rpc.polkadot.io/']); // alexandersubstrate.setNodeUri(['ws://127.0.0.1:9944/']);// local// track chain heightvarchain=substrate.chain;chain.height.tie((height)=>{console.log('[chain height] '+height);})// register accountsvarsystem=substrate.system;varsecretstore=substrate.secretStore();// if running a plain substrate node, alice will have genesis hard-coded funds varalice_seed='0x416c696365202020202020202020202020202020202020202020202020202020';varalice_accountid=secretstore.submit(alice_seed,'Alice');// new acount without fundsvarnewbie_seed='0x4e65776269652020202020202020202020202020202020202020202020202020';varnewbie_accountid=secretstore.submit(newbie_seed,'Newbie');// sign some stringvarmsg=newutil.TextEncoder().encode('this is true');varmsg_sig=secretstore.sign(alice_accountid,msg);// populate runtime (query RPC)substrate.runtimeUp.then(()=>{varruntime=substrate.runtimevarcalls=substrate.callsvarpost=substrate.post// track Alice's balanceruntime.balances.freeBalance(alice_accountid).tie((bal)=>{console.log('[Alice balance] '+bal);})// track Newbie's balanceruntime.balances.freeBalance(newbie_accountid).tie((bal)=>{console.log('[Newbie balance] '+bal);})// send funds and track tx progresspost({sender: alice_accountid,call: calls.balances.transfer(newbie_accountid,1000000)}).tie((data)=>{if(data.finalised){console.log('>>> tx finalized')}})})
As I was missing an example on how to use oo7-substrate with nodejs to call some runtime function, I hacked one up. Would be great if you could include this (and possibly more interesting examples)