Skip to content

Quickstart ​

From zero to a deployed token on a local network, in about ten minutes.

Before you start

The public network is not running yet, so this guide uses a node and a gateway on your machine. Start them with CHAIN_ENV=testnet (it enables the faucet) — see Run a node. Then:

bash
export NODE_RPC=http://localhost:9933
export GATEWAY=http://localhost:3000

1. Check the network ​

bash
curl -s "$GATEWAY/api/v1/network/status"
curl -s "$NODE_RPC/health"

height should grow every few seconds. bft_ready: false on a single local node is expected — it means fewer than 7 validators.

2. Get a wallet ​

Open the web app (http://localhost:8080), choose Create wallet, and write down the 24 words. The app shows your neuro:<15 hex>.human address.

Or derive it in your own page with the SDK:

js
import { NeuroChain } from './neurochain.js'

const nc = new NeuroChain({ gateway: 'http://localhost:3000' })
const wallet = await nc.walletFromMnemonic('<your 24 words>')
console.log(wallet.address, wallet.publicKey)

Signing needs the crypto WASM module, which the SDK loads in the browser. See JavaScript SDK → Crypto.

3. Fund it ​

bash
curl -s -X POST "$NODE_RPC/api/v1/faucet" \
  -H 'Content-Type: application/json' \
  -d '{"address":"neuro:<15 hex>.human","public_key":"<public key hex>"}'

The faucet gives 50 test NRO by default and binds your public key to the address. The web app has a Faucet button that does the same.

bash
curl -s "$GATEWAY/api/v1/accounts/neuro:<15 hex>.human"

Look at balance_human (NRO) and nonce.

4. Send NRO ​

SDK transfers are broken in the current build

nc.transfer() sends the amount as a JSON string and the node refuses it (Missing from/to/value). Until the SDK is fixed, send the transfer with a numeric value — see JavaScript SDK → Known issues.

js
import { toRaw } from './neurochain.js'

const { base_fee } = await nc.gasEstimate()
const gas_price = Math.ceil(base_fee * 1.5)          // stay above the base fee
const to = 'neuro:<another address>.human'
const value = Number(toRaw('1.5'))                   // 1.5 NRO in uNRO, as a number
const nonce = await nc.nextNonce(wallet.address)
const sig = wallet.sign(to, value, nonce)            // { signature, public_key }

const res = await fetch('http://localhost:3000/api/v1/transactions', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ from: wallet.address, to, value, nonce, gas_price, ...sig }),
}).then(r => r.json())
// { tx_hash, status: 'pending', estimated_block, sentinel_score, … }

The response carries the transaction hash with status pending; a second later GET /api/v1/transactions/:hash shows confirmed.

5. Deploy a token ​

The repository ships a compiled NRC-20 token at neurochain/contracts/nrc20/nrc20.hex.

js
const bytecodeHex = (await (await fetch('/nrc20.hex')).text()).trim()
await nc.deployContract({
  wallet,
  bytecodeHex,
  name: 'MyToken',
  template: 'nrc20',
  initArgs: { name: 'MyToken', symbol: 'MTK', decimals: 6, total_supply: '1000000' },
})

The deploy is a transaction to neuro:system.deploy. Every validator runs the VMGuardian audit on the bytecode, creates the contract at neuro:<10 hex>.app and calls initialize with your initArgs. Give total_supply in whole tokens and decimals as a number: the node converts the supply to the token's smallest unit (1000000 at 6 decimals becomes 10¹² units), all minted to you. The NRC-20 bytecode in the repository is on the trusted list, so it gets security score 100. Find the address in your transaction history or GET /api/v1/contracts.

6. Read and call the contract ​

js
const token = 'neuro:<10 hex>.app'

// Read — runs without a transaction, no gas
await nc.contractQuery(token, 'balance_of', { address: wallet.address })
// → '{"ok":true,"value":1000000000000}'  (smallest units)

// Write — a signed transaction with JSON call data
await nc.contractCall({
  wallet,
  address: token,
  fn: 'transfer',
  args: { to: 'neuro:<another address>.human', amount: '250' },  // whole tokens — the node converts
  gasPrice: Math.ceil(base_fee * 1.5),
})

The contract learns who called it from the host (get_caller()), never from the arguments. See ABI & call data.

Next ​