-
Notifications
You must be signed in to change notification settings - Fork 9
Connection
Nikhil Ranjan edited this page Sep 22, 2022
·
2 revisions
To connect to astar/shiden node first install the dependencies and use ApiPromise with options.
yarn add @polkadot/api @astar-network/astar-api
Create API instance:
import { ApiPromise } from '@polkadot/api';
import { WsProvider } from '@polkadot/rpc-provider';
import { options } from '@astar-network/astar-api';
async function main() {
const provider = new WsProvider('ws://localhost:9944');
// OR
// const provider = new WsProvider('wss://shiden.api.onfinality.io/public-ws');
const api = new ApiPromise(options({ provider }));
await api.isReady;
// Use the api
// For example:
console.log((await api.rpc.system.properties()).toHuman());
process.exit(0);
}
main()