Skip to main content
Farmland investment platforms let a diaspora investor in London or a saver in Nairobi buy a fractional stake in a real parcel of farmland back home, in the local currency they already have — not crypto. This tutorial builds the bare bones of that product: a FarmlandToken deployed per parcel, a small backend that turns an NGN or KES deposit into minted shares via RampManager, and a React page investors use to check their position.

What you’ll build

  • An admin script that deploys one FarmlandToken per parcel with real metadata (location, valuation, soil type, title document hash)
  • An Express API with three routes: get an on-ramp quote, start an investment (fiat → shares), and a webhook that mints shares once the deposit settles
  • A React investor dashboard using useAsset and useTokenBalance

Prerequisites

  • Node.js 18+
  • A Stellar testnet account and secret key (S...) — fund it with the Stellar Friendbot
  • npm install @ankarachain/sdk express (add ethers too if you also want the EVM path shown below)
Keep STELLAR_SECRET_KEY in .env, never in application code or version control. The mint step below runs server-side with the platform’s own admin key — investors never handle a private key.

1

Scaffold the project

src/config.ts builds the two SDK clients every route needs — a TokenFactory for the platform’s admin signer, and a RampManager wired to a fiat provider:
src/config.ts
ManualRampProvider is the right default while you build — it needs no API keys and lets you drive sessions to "settled" yourself in tests. Swap in RampManager.connectAnchor() for a real Stellar anchor (Cowrie, MoneyGram) when you go live — see the Fiat Ramp guide.
2

Deploy a FarmlandToken per parcel

Run this once per parcel you onboard. It’s the same TokenFactory.deployFarmland() call whether you’re on Stellar or EVM — only the config passed to TokenFactory changes.
src/deploy.ts
Save the resulting tokenAddress — your platform’s database should map each parcel to its deployed token address and template ("farmland").
3

Quote and initiate an investment

An investor picks a parcel and an amount in their local currency. Get a quote, then start an on-ramp session:
src/routes.ts
4

Mint shares once the deposit settles

In production, your fiat provider calls a webhook when the payment clears. Verify the payload, then mint shares to the investor and record the transition to ACTIVE:
src/routes.ts (continued)
The first mint() call on a token automatically transitions it from DRAFT to ACTIVE on-chain — the explicit setStatus() call above is only needed if your platform wants to flip a token to ACTIVE before the first sale (e.g. once KYC and legal review finish). See Mint Tokens for the full lifecycle.
5

Show investors their position

Read-only, no signer required — safe to run for any visitor:
src/components/ParcelPosition.tsx

Going further

Next steps

TokenFactory

Full reference for deployFarmland and every other deploy method.

RampManager

Quotes, sessions, providers, and on-chain settlement in depth.

AssetRegistry

Reading and writing metadata on a deployed token.

React Hooks

useAsset, useTokenBalance, and useAnkaraChain in full.