Files
api/docs/examples-rpc/01_simple_connect/index.js
T
Jaco Greeff a4fc2c51e8 API documentation (#253)
* Remove badges from READMEs (used inside docs)

* Expand intro

* Intro and examples for ApiRx

* examples -> examples-rpc

* Update intros with expanded example

* Don't nest subscriptions
2018-10-11 15:27:00 +02:00

17 lines
418 B
JavaScript
Executable File

const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/rpc-provider/ws').default;
const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Rpc(provider);
async function getChain () {
return api.system.chain();
}
async function main () {
const chain = await getChain();
console.log('You are connected to chain:', chain);
}
main().finally(_ => process.exit());