Numbers Protocol

Commit via nit module

Using the nit module to create asset commits is free, but there will still be a gas fee associated with the transaction. To ensure that the transaction can be completed, it is important to have Mainnet NUM or Testnet NUM in the wallet being used.
Before starting, make sure nit is installed in your working environment. Here are the basic steps to commit via the nit module.
  1. 1.
    Prepare nit config
  2. 2.
    Generate AssetTree
  3. 3.
    Create commit

Prepare nit config

In order to commit via nit module, you need to complete the following steps:
  • Follow Infura document and acquire YOUR_INFURA_PROJECT_ID and YOUR_INFURA_PROJECT_SECRET
  • Create a wallet and set up YOUR_PRIVATE_KEY in order to commit and create transactions. This wallet will appear as the committer in the Commit.
  • Make sure there are Mainnet NUM in the wallet
  • [Option] Make sure there are Testnet NUM in the wallet
const config = {
"defaultNetwork": "jade",
"provider": "bafkreigrt5tepycewppysdwcjccdkdvvc2ztelqv64idgautq52g3vfh4i",
"infura": {
"network": {
"jade": {
"url": "",
"chainId": 10507,
"accounts": [
"contract": "0x7EC2F14ABE8b0Ea2F657bBb62b6fEfDe161c9001",
"explorerBaseUrl": ""
"snow": {
"url": "",
"chainId": 10508,
"accounts": [
"contract": "0x02eFA51b583d03342687b585417e5A62cd8273a4",
"explorerBaseUrl": ""
//Set defaultNetwork to snow if testnet is enabled
if(testnet === true){
config.defaultNetwork = "snow"

Create Commit

The following example is an example to create a commit for the asset on Numbers Mainnet using nit library. Before you start, follow the AssetTree spec to prepare the information for your asset and put them in the inputData.
import ipfs from "@numbersprotocol/nit/lib/ipfs.js";
import nit from "@numbersprotocol/nit/lib/nit.js";
async function main(inputData, config) {
const blockchainInfo = await nit.loadBlockchain(config);
//create the basic assetTree
await ipfs.initInfura(config.infura.projectId, config.infura.projectSecret);
let assetTree = await nit.createAssetTreeInitialRegister(
//Set asset abstract
if (inputData.abstract) {
assetTree.abstract = inputData.abstract;
//check license and set it as null if no license is assigned
if (inputData.licenseName) { = inputData.licenseName;
} else { = null;
if (inputData.licenseDocument) {
assetTree.license.document = inputData.licenseDocument;
} else {
assetTree.license.document = null;
//if there are custom fields, add to assetTree
if (inputData.custom !== null) {
assetTree = await nit.updateAssetTree(assetTree, JSON.parse(inputData.custom));
let author;
if ( {
author =;
} else {
author = blockchainInfo.signer.address;
//Initialize nit
const commit = await nit.createCommitInitialRegister(
const commitResult = await nit.commit(inputData.assetCid, JSON.stringify(commit), blockchainInfo);
"txHash": commitResult.hash,
"assetCid": assetTree.assetCid,
"assetTreeCid": commit.assetTreeCid,
Please replace the "YOUR_PRIVATE_KEY" with your own private key in the config. The following is the package.json used by this example:
"dependencies": {
"@numbersprotocol/nit": "^1.2.6"

Commit with NFT Records

If your asset has been minted as NFTs and you wish to include NFT records in the AssetTree, please follow the specifications outlined in the nftRecord documentation to prepare the nftRecord file. Then, add the following code to your AssetTree preparation process.
//Update NFT related data
if (inputData.nftChainID !== null) {
const nftRecord = {
"network": inputData.nftChainID,
"contractAddress": inputData.nftContractAddress,
"tokenId": inputData.nftTokenID,
const nftRecordBytes = Buffer.from(JSON.stringify([nftRecord], null, 2));
assetTree.nftRecord = await ipfs.infuraIpfsAddBytes(nftRecordBytes);