Skip to main content
TokenFactory is the primary entry point for deploying Ankara Chain RWA tokens onto EVM chains (Polygon, Ethereum, BNB Chain, Celo) and Stellar Soroban. It wraps the on-chain factory contract in a developer-friendly, fully typed API that selects the correct adapter — EVMAdapter or StellarAdapter — based on the network field you pass to the constructor.

Import


Constructor

The constructor accepts a discriminated-union config. Set network to an EVM network name and TypeScript narrows the type to EVMAnkaraChainConfig; set it to "stellar" or "stellar-testnet" and it narrows to StellarAnkaraChainConfig.

EVMAnkaraChainConfig

"polygon" | "polygon-amoy" | "ethereum" | "bnb" | "celo" | "localhost"
required
The EVM network to target. Selects the correct default RPC URL, chain ID, and factory contract addresses.
ethers.Signer
An ethers Signer used to sign deployment transactions. Required for any write operation; omit if you’re only reading.
ethers.Provider
An ethers Provider. If omitted, a JsonRpcProvider is constructed from rpcUrl (or the network default).
string
Override the default ERC-20 TokenFactory contract address.
string
Override the default NFT factory contract address.
string
Override the default EscrowFactory contract address.
string
Override the default ERC-1155 MultiTokenFactory contract address.
string
Override the default RampSettlementFactory contract address.
string
Override the default RPC endpoint for the selected network.

StellarAnkaraChainConfig

"stellar" | "stellar-testnet"
required
Targets the Stellar Soroban mainnet or the public testnet.
string
A Stellar secret seed (starts with "S..."). Server-side and CLI use only — never pass a raw secret key in a browser. Use stellarSigner instead for browser contexts.
StellarExternalSigner
An external wallet signer such as Freighter. Mutually exclusive with stellarSecretKey; if both are provided, stellarSecretKey takes precedence.
string
Soroban contract ID (starts with "C...") for the token factory. Override only if you deploy your own factory instance.
string
Override the default NFT factory Soroban contract ID.
string
Override the default EscrowFactory Soroban contract ID.
string
Override the default MultiTokenFactory Soroban contract ID.
string
Override the default RampSettlementFactory Soroban contract ID.
string
Override the default Soroban RPC endpoint for the selected Stellar network.
Never use stellarSecretKey in a browser. The raw Stellar secret seed gives full control of the account. In any browser or mobile context, use stellarSigner with a SEP-43-compatible wallet like Freighter — the secret seed never needs to leave the wallet extension.

EVM example

Stellar example (server-side)

Stellar example (browser / Freighter)


Fungible Token Methods

deployFarmland

Deploys a new FarmlandToken ERC-20 (EVM) or SEP-41 (Stellar) via the on-chain factory. The token represents fractional ownership of agricultural land.
string
required
Human-readable token name, e.g. "Kano Farmland Token".
string
required
Ticker symbol, e.g. "KFT".
string
required
Your off-chain asset identifier, e.g. "KANO-FARM-001". Stored on-chain for indexing.
string
required
ISO 3166-1 alpha-2 country code, e.g. "NG" for Nigeria.
FarmlandMetadata
required
Template-specific metadata struct (see below).
string
Address granted DEFAULT_ADMIN_ROLE. Defaults to the connected signer.
string
Address of an on-chain identity verifier for KYC-gated transfers. Pass the zero address (or omit) to allow unrestricted transfers.
FarmlandMetadata fields: Returns: Promise<DeployResult>
string
The address of the newly deployed token contract.
string
Transaction hash of the deployment transaction.
string
Echo of the assetId you supplied.
AssetTemplate
Always "farmland" for this method.
SupportedNetwork
The network the token was deployed on.
number
Unix timestamp of the deployment.
Full example:

deployCommodity

Deploys a CommodityReceiptToken representing warehouse-receipted physical commodities (grain, cocoa, coffee, etc.).
CommodityMetadata
required
Warehouse receipt metadata including commodity type, quantity, warehouse ID, and inspection report hash.
CommodityMetadata key fields:

deployRealEstate

Deploys a RealEstateToken for fractional property ownership. Supports residential, commercial, industrial, and land asset types. RealEstateMetadata key fields:

deployInvoice

Deploys an InvoiceToken for invoice financing / trade receivables. The token tracks an invoice lifecycle from PENDING → FUNDED → REPAID / DEFAULTED. InvoiceMetadata key fields:

deployCarbonCredit

Deploys a CarbonCreditToken representing verified emissions reductions. Supports retirement events tracked entirely on-chain. CarbonCreditMetadata key fields:

deployMiningRights

Deploys a MiningRightsToken representing fractional mining licence ownership. Tracks licence expiry and royalty declarations on-chain. MiningRightsMetadata key fields:

NFT Methods

Each NFT method deploys a non-fungible (ERC-721 / Soroban NFT) version of the asset, where individual tokens can represent distinct parcels or units.

deployFarmlandNFT

deployRealEstateNFT

deployMiningRightsNFT

deployCommodityVaultNFT

All NFT deploy options extend BaseDeployNFTOptions (same name, symbol, assetId, countryCode, admin, identityVerifier fields as fungible tokens) plus a template-specific metadata struct. NFTDeployResult fields:
string
Address of the deployed NFT contract.
string
Deployment transaction hash.
NFTAssetTemplate
One of "farmland-nft", "real-estate-nft", "mining-rights-nft", "commodity-vault-nft".
You can query all NFT contracts deployed by a wallet:

Multi-Token Methods

deployCommodityBatchToken

Deploys a CommodityBatchToken (ERC-1155 on EVM) — a multi-batch warehouse receipt where each token ID represents a distinct commodity lot in the same warehouse.
string
required
Contract-level name for the collection.
string
required
ISO 3166-1 alpha-2 country code.
string
required
Base URI for per-token metadata (e.g. an IPFS gateway URL).
WarehouseMetadata
required
Warehouse operator details including warehouseId, warehouseLocation, operatorAddress, warehouseLicenseHash, and certificationExpiry.

deployPoolVault

Deploys a PoolVault — a multi-asset ERC-20 fund that holds a basket of Ankara RWA tokens and issues proportional LP shares.
string
Address of an on-chain price oracle. Defaults to address(0) (no oracle — NAV calculations are manual until one is set).
number
Annual management fee in basis points. Defaults to 0.
MultiTokenDeployResult fields:
string
Address of the deployed multi-token contract.
MultiTokenTemplate
Either "commodity-batch" or "pool-vault".

Escrow Methods

deployEscrow

Deploys a new MilestoneEscrow contract via the on-chain EscrowFactory. The escrow holds funds in milestone-sized chunks — the payer can fund each milestone independently, paying in installments rather than up-front.
string
required
Address of the payer (buyer / client).
string
required
Address of the payee (seller / contractor).
string
required
Address of the stablecoin to use for payment. Must be whitelisted on the EscrowFactory contract.
EscrowMilestoneInput[]
required
Array of milestone definitions. Each entry has amount (in wei) and an optional descriptionHash (bytes32 hex).
string
Address of a neutral third party who can resolve disputes. Defaults to address(0) (no arbiter).
number
How long after delivery the payer has to approve or dispute before the payee can claim automatically. Defaults to 7 days on-chain.
EscrowDeployResult fields:
string
Address of the deployed MilestoneEscrow contract.
bigint
Sum of all milestone amounts in wei.

Ramp Settlement Methods

deployRampSettlement

Deploys an on-chain RampSettlement contract — the optional on-chain custody half of a fiat on/off-ramp flow. Off-ramp tokens are held here before the treasury receives them; on-ramp mints are attested here after the fact. Use RampManager for the off-chain provider orchestration side.
string
required
Address that receives settled off-ramp token proceeds.
string
Address granted admin rights over the contract. Defaults to the connected signer.
RampSettlementDeployResult fields:
string
Address of the deployed RampSettlement contract.
string
The treasury address as set on-chain.

Query Methods

All getDeployedXxx() methods accept an optional address?: string — omit it to query the connected signer’s deployments, or pass any wallet address to query another deployer’s history.

Properties


Type Reference

All address overrides (factoryAddress, nftFactoryAddress, etc.) are optional. The SDK ships with default addresses for every supported network. You only need to set these when deploying to "localhost" or when pointing at a custom factory deployment.