Node API
Explore Avail DA's Node API endpoints for balances, staking, data availability, and nomination pools.
Note
BEFORE WE START
- The Avail node supports an extensive list of extrinsics and various other types of calls that you can try out in our explorer.
- This API reference currently documents only the most widely used extrinsics, but will be iterated upon to eventually be an exhaustive resource for the Avail node API.
Setting up the dev environment
- Make sure
Node-jsis installed on your system by running the following command in your terminal:
node --version- Create a new Node-js project by running the following command in a directory of your choice:
pnpm init- To install the
avail-js-sdkrun the following command:
pnpm add avail-js-sdk@0.4.1- Make sure to install the
ts-nodepackage if you haven't already:
pnpm add -g ts-node- Create a
tsconfig.jsonfile in the root of your project by running:
touch tsconfig.json- Populate your
tsconfig.jsonwith the following configuration:
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"outDir": "build",
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"noUnusedParameters": true
},
"include": ["**/*.ts", "**/*.js"],
"exclude": ["node_modules", "build"]
} - Create a
.envfile in the root of your project by running:
pnpm add dotenv && touch .env- Put in the Seed Phrase of the account you want to use into the
.envfile:
SEED="This is a random seed phrase please replace with your own"🔥Error
IMPORTANT
- Please be VERY CAREFUL with your seed phrase.
- Make sure to add your
.envfile to your.gitignoreso that it doesn't get pushed anywhere. - While it is good enough to use an
envfile while testing, try to use better practices while deploying to production.
How is this guide?