This repository contains examples of how to use the polkadot{.js} API to connect to a node and perform some basic operations.
Join the discussion in our Telegram Group 💬
Pre-requisites:
- Setup Node.js v18+ (recommended via nvm with
nvm install 18
)- Clone this repository
Special Instructions for Windows Users
[!IMPORTANT]
PowerShell is not supported. Windows users must either use WSL (recommended) or a custom shell like Git Bash.
Pre-requisites when using WSL for Linux:
- Install WSL and execute all commands in the WSL terminal
- Setup Node.js v18+ (recommended via nvm with
nvm install 18
)- Install the following npm packages globally:
npm i -g npm
npm i -g pnpm node-gyp make
- Clone this repository into the WSL file system (e.g.
/home/<user>/
).Tip: You can enter
\\wsl$\
in the top bar of the Windows Explorer to access the WSL file system visually.
Install dependencies:
pnpm install
## or
npm install
## or
yarn install
Run a script:
Note
These commands will run a TypeScript script directly using tsx
. Alternatively, you can build the TypeScript files and run the JavaScript output using node
.
pnpm run script traverse-events-at-block
## or
npm run script traverse-events-at-block
## or
yarn run script traverse-events-at-block
Note
You can use this repository as a starting point for your own scripts, ignore the examples, and uninstall redundant dependencies.
Macros | Description | Dependencies |
---|---|---|
balance |
Fetches the balance for a given network & address. | @polkadot/api @scio-labs/use-inkathon @azns/resolver-core |
listen-contract-events |
Listens & decodes ink! contract events. | @polkadot/api @polkadot/api-contract |
traverse-events-at-block |
Traverses all events at a specific block. | @polkadot/api |
The project is part of a Scio Labs initiative to improve the developer experience in the ink! ecosystem. Other projects include:
create-ink-app
CLI (Coming soon)ink!athon
BoilerplateuseInkathon
Hooks & Utility Libraryzink!
Smart Contract Macros