Phu Quoc Dog
Search…
Introduction
The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript. Here you will find documentation and examples to get you started.
Jump right in and get an overview on using the API in your projects, from installation all the way through to making it do magic. Have things working and want tips? The cookbook provides some tips and tricks.
For oft-repeated questions, the FAQ may have what you are looking for.
All documents you can see at https://polkadot.js.org/docs/api/start****

Simple Connect

The following example shows how to instantiate a Polkadot API object and use it to connect to a node using ApiPromise.
1
// Some code
2
// Required imports
3
const { ApiPromise, WsProvider } = require('@polkadot/api');
4
5
async function main () {
6
// Initialise the provider to connect to the local node
7
const provider = new WsProvider('wss://rpc01.phuquoc.dog');
8
9
// Create the API and wait until ready
10
const api = await ApiPromise.create({ provider });
11
12
// Retrieve the chain & node information information via rpc calls
13
const [chain, nodeName, nodeVersion] = await Promise.all([
14
api.rpc.system.chain(),
15
api.rpc.system.name(),
16
api.rpc.system.version()
17
]);
18
19
console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
20
}
21
22
main().catch(console.error).finally(() => process.exit());
Copied!

Generate address

The Keyring allows you to manage a set of keys in a consistent environment, allows you to perform operations on these keys (such as sign/verify) and never exposes the secretKey to the outside world.
To get started, follow the getting started journey for installation and use. For oft-repeated questions, the FAQ may have what you are looking for.
Copy link
Edit on GitHub