Code examples
Futureverse’s examples of building on The Root Network, each with its README and every source file. The official docs list them as “Curated Examples”.
Copied from Futureverse’s
futureversecom/trn-examples, deleted with its GitHub organisation, at commit44c9e16of 2024-10-31. Apache-2.0: license.
Most are short TypeScript scripts that each do one thing: send an extrinsic through the native API, or call a precompile through the EVM. Two are Solidity projects that deploy a contract, one with Foundry and one with Hardhat.
Running the examples
Porcini is down
The examples run on Porcini, the testnet. Porcini did not answer: its RPC address leads to a server that is not a TRN node, under another site’s TLS certificate (checked 2026-10-18). As written, they fail when they connect; once Porcini is back, they run as they are.
They can run on Root mainnet instead, with a funded account and care:
- In each script, change
"porcini"to"root"where it callswithChainApiorwithEthersProvider. The Foundry and Hardhat projects need a mainnet RPC and chain id 7668. - Fund the account with XRP for gas. Every run spends real tokens, and what it makes (collections, listings, FuturePasses) stays on chain.
- Asset ids differ:
porcini-assets.tshas Porcini’s. Mainnet’s are in Asset IDs, and the RPCs and how they last answered in Networks & RPCs.
To run one, install the workspace with pnpm install, set CALLER_PRIVATE_KEY to the account’s private key, and run the example’s scripts from its folder, as its README shows. The guides show how upstream made a test account.
Native API
Scripts that send extrinsics with @polkadot/api and @therootnetwork/api.
- Assets — Transfer a fungible asset. Reference: assets pallet.
- DEX — Swap one token for another, and add or remove liquidity. Reference: dex pallet.
- FeeProxy — Pay gas in a token other than XRP, around a remark, a batch, an EVM call and a FuturePass proxy call. Reference: feeProxy pallet.
- FuturePass — Create a FuturePass, send an extrinsic through it, register a delegate and decode a proxy error. Reference: futurepass pallet.
- FuturePass multisig — Make a multisig wallet with a FuturePass among its signers, and approve a transfer from it with a second signer. Reference: multisig pallet.
- Marketplace — Register a marketplace, list NFTs for sale or auction, buy and bid. Reference: marketplace pallet.
- NFT — Create and update an NFT collection, mint and transfer. Reference: nft pallet.
- SFT — Create and update an SFT collection and its tokens, mint and transfer. Reference: sft pallet.
- Utility — Send extrinsics as a batch, and decode a batch error. Reference: utility pallet.
EVM
Scripts that call the precompiles with ethers, and two contract projects.
- ERC-20 — Transfer an asset through its ERC-20 precompile. Reference: ERC-20 precompile.
- ERC-721 — Create and update an NFT collection, and mint, through the precompiles. Reference: ERC-721 precompile.
- ERC-1155 — Create and update an SFT collection, create a token and mint, through the precompiles. Reference: ERC-1155 precompile.
- FeeProxy — Pay the gas for an ERC-20 transfer in a token other than XRP. Reference: FeeProxy precompile.
- Foundry — Deploy, verify and test a Solidity contract with forge. Reference: smart contract cookbook.
- FuturePass — Create a FuturePass, make a call through it and register a delegate. Reference: FuturePass precompile.
- Hardhat — Deploy and verify a Solidity contract with hardhat-deploy. Reference: smart contract cookbook.
The rest of the repository
- Workspace and shared helpers — the pnpm workspace the examples run in, and
@trne/utils, the helpers they import. - Guides — create and fund a test account.
- License — the Apache License 2.0, from the repository’s
LICENSEfile.
Credit
The examples are Futureverse’s. They are copied from futureversecom/trn-examples at commit 44c9e16 of 2024-10-31, the last on its main branch, and are under the Apache License 2.0: license text. The source files are shown as they were. The READMEs are changed only in form: their links point at this site, their badges are plain links, and comments GitHub hid are left out.
Source:
futureversecom/trn-examples (deleted) · commit 44c9e16, 2024-10-31 · Apache-2.0, license · part of Code examplesAssociated docs
Where else you might go from here. Following one is optional — this chapter stands without them.
- Guides for the code examples
Prerequisite— How Futureverse’s TRN code examples get a test account: create one in MetaMask and fund it from the Porcini faucet.- Workspace and shared helpers (code examples)
Prerequisite— The pnpm workspace Futureverse’s TRN code examples run in, and @trne/utils, the helpers their scripts import.- Part II — Building
Part of— The two API tracks — EVM and Substrate — plus the Asset Register, the contracts deployed on TRN, and the recipes for common work.- @futureverse/react-unity-viewer
See also— Futureverse React Unity Viewer provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way…- @futureverse/sylo-notifications-sdk
See also— This SDK provides utility functions for broadcasting and subscribing to Futureverse Notifications sent over the Seekers Node Network.- @therootnetwork/api
See also— A utility package that complements the @polkadot/api to connect and interact with the Root Network node.- @therootnetwork/doughnut-nodejs
See also— JS/Wasm bindings for the rust Doughnut codec- @therootnetwork/doughnut-web
See also— JS/Wasm bindings for the rust Doughnut codec