Minimal, copy-pasteable Node.js examples for common tasks on The Root Network (Porcini & Mainnet).
Each script is a tiny, focused demo you can skim, run, and adapt.
- ✅ Uses
@therootnetwork/api+@polkadot/api - ✅ Simple
signAndSendwith an event log + “waiting loop” - ✅ Human-readable comments & obvious placeholders
- ✅ Persona keys to keep examples consistent (Steve, Jane, Cody, Sarah)
⚠️ Never commit real private keys. The demo keys in these scripts are placeholders for local testing only.
# 1) Clone
git clone https://github.com/sdoddler/TheRootNetwork---Helpful-Scripts.git
cd TheRootNetwork---Helpful-Scripts
# 2) Install deps
npm i @polkadot/api @therootnetwork/api @polkadot/keyring @polkadot/util dotenv
# (optional) If you prefer yarn
# yarn add @polkadot/api @therootnetwork/api @polkadot/keyring @polkadot/util dotenvTested with Node 18+ (recommended: Node 20.x).
Scripts default to Porcini via:
ApiPromise.create({ ...getApiOptions(), ...getPublicProvider("porcini") })
To point at Mainnet, swap "porcini" to "mainnet" (or pass your own provider).
Most scripts import persona keys like:
Steve – collection creator / token sender
Jane – typical user / seller
Cody – validator / nft holder
Sarah – typical user / buyer
You can:
Replace inline placeholders in each script, or
Use environment variables via .env (recommended)
.env example:
STEVE_PRIVATE_KEY=0xYOURSTEVEPRIVKEY
JANE_PRIVATE_KEY=0xYOURJANEPRIVKEY
CODY_PRIVATE_KEY=0xYOURCODYPRIVKEY
SARAH_ADDRESS=0xYourSarahAddress
And load it in scripts with:
require("dotenv").config();
Project Structure
.
├─ scripts/
│ ├─ tokens/
│ │ ├─ create_token.js
│ │ └─ send_token_query_balance.js
│ ├─ transfers/
│ │ └─ root_transfer.js
│ ├─ nfts/
│ │ ├─ nft_create_collection.js
│ │ ├─ nft_enable_public_mint.js
│ │ ├─ nft_set_royalties.js
│ │ ├─ nft_transfer.js
│ │ ├─ nft_enable_nfi.js
│ │ └─ nft_check_ownership.js
│ ├─ validator/
│ │ └─ validator_set_commission.js
│ └─ batch/
│ ├─ batch_transfer_tokens.js
│ └─ batch_list_nfts_for_sale.js
└─ README.md
Script Catalog & How to Run
All commands run from repo root. Replace IDs/addresses where noted.
e.g. to Create a new token after replacing the values
node scripts/tokens/create_token.js
MIT — do cool stuff, don’t ship your real keys.