Skip to main content
This guide walks you through deploying a tokenized farmland asset on Polygon Amoy testnet using the Ankara Chain CLI and TypeScript SDK. By the end you will have a live ERC-20 token backed by on-chain asset metadata, minted fractional shares to an investor address, and a working TypeScript snippet you can drop into your application. The same steps apply to Ethereum, BNB Chain, and Celo — only the network name in your config changes.

Prerequisites

  • Node.js 18+ installed locally
  • A throwaway wallet private key — never use a key that holds real funds for testnet work
  • Polygon Amoy testnet MATIC — get free tokens at faucet.polygon.technology
Keep your private key in .env only. The ankara init wizard adds .env to .gitignore automatically, but double-check before your first git push.

1

Install the SDK and CLI

Install the Ankara Chain TypeScript SDK as a project dependency:
Or install the CLI globally so you can run ankara commands from any directory:
You can also use the CLI without installing it globally by prefixing every command with npx:
The SDK has ethers as a peer dependency. If your project does not already have it, install ethers v6 alongside the SDK: npm install ethers.
2

Initialize your project

Run the ankara init wizard to scaffold a project directory and generate your config:
The wizard prompts you for three things:
After the wizard completes, your project directory looks like this:
The generated ankara.config.json starts with just the network set:
ankara init writes PRIVATE_KEY= to .env and adds .env to .gitignore. Confirm .gitignore exists and contains .env before committing anything.
3

Deploy the Token Factory

The on-chain TokenFactory contract must be deployed once per network before you can issue tokens. It acts as a registry and deployment hub for all asset tokens you create.
The CLI reads your PRIVATE_KEY from .env, deploys the factory contract to Polygon Amoy, and writes the resulting address back to ankara.config.json:
You only run deploy-factory once. After the factory address is saved in ankara.config.json, all subsequent ankara deploy and ankara mint commands read that address automatically.
4

Deploy a token

With the factory deployed, you can now issue your first RWA token. Run the interactive deploy wizard:
The wizard walks you through selecting an asset template and filling in the asset-specific metadata. Here is an example session deploying a tokenized farmland parcel in Kano State, Nigeria:
The six available asset templates are: Farmland, Commodity, Real Estate, Invoice, Carbon Credit, and Mining Rights. Each template has its own metadata schema — see Asset Templates for the full field reference.
5

Mint tokens

Mint fractional shares of the deployed asset to an investor address:
The CLI prompts you to select the deployed token (from ankara.config.json), enter the recipient address, and specify the amount to mint. Token amounts use 18 decimal places by default, matching the ERC-20 standard.
To mint programmatically from your application code, use the AssetRegistry class from @ankarachain/sdk or call the mint method directly on the deployed ERC-20 contract via ethers.js.

Using the SDK Directly

The CLI is a wrapper around the @ankarachain/sdk TypeScript API. For programmatic use in your application — server-side deployment scripts, backend APIs, or automated workflows — use the SDK directly:
The deployFarmland() call returns a DeployResult object:
The TokenFactory constructor accepts a factoryAddress override. If you omit it, the adapter uses the default factory address for the network — useful once Ankara Chain ships mainnet factory deployments. You can also pass rpcUrl to override the default RPC endpoint, or provider if you already have an ethers Provider instance in scope.

React Hooks

The @ankarachain/sdk/react entry point exports React hooks that wrap the SDK for use in front-end applications. Import from the separate entry point to avoid pulling React into server-side bundles:
The hooks handle provider setup, subscription to on-chain events, and re-rendering when token state changes — so your component always reflects current on-chain data without manual polling.

Next Steps

Stellar Quickstart

Deploy the same token on Stellar Soroban testnet using the unified SDK API.

Asset Templates

Explore full metadata schemas for all six asset classes.

CLI Commands

Full reference for every ankara command and flag.

TokenFactory SDK

Programmatic deploy API with full TypeScript type signatures.