Skip to main content
A licensed gold concession in Ashanti generates royalty income for whoever holds a stake in it — but that stake is illiquid until the licence runs out. This tutorial builds a MiningRightsToken platform where holders can also borrow stablecoin against their royalty tokens without selling them, using CollateralVault. That lending primitive is Stellar/Soroban-only in the SDK’s current version, so this whole tutorial stays on Stellar rather than switching networks partway through.

What you’ll build

  • An admin script that deploys one MiningRightsToken per concession licence
  • A royalty declaration job and a licence-expiry sweep
  • A borrowing flow: a holder locks royalty tokens as collateral and draws a stablecoin loan via CollateralVault
  • A React panel showing a holder’s token balance alongside their open loan’s live loan-to-value ratio

Prerequisites

  • Node.js 18+
  • A Stellar testnet account and secret key (S...), funded via the Stellar Friendbot
  • npm install @ankarachain/sdk express node-cron
CollateralVault is a singleton per network — you don’t deploy it yourself, and it isn’t available on EVM in the current SDK version. The testnet vault address below is the shared Ankara Chain Stellar Testnet deployment. See CollateralVault.

1

Scaffold the project

src/config.ts
2

Deploy a token per concession

src/routes.ts
3

Declare royalties and track licence expiry

declareRoyalty() only records an on-chain declaration of the royalty owed for a given extraction value — it doesn’t move funds. Pay holders off-chain first (proportional to their share of getTotalSupply(), the same pattern used in the Real Estate Income Platform tutorial’s rental distribution step), then declare:
src/routes.ts (continued)
src/jobs/expireLicenses.ts
A licence holder who renews can extend expiry directly: await registry.renewLicense(newExpiryUnixSeconds).
4

Let holders borrow against their tokens

A holder locks some of their MiningRightsToken balance as collateral and borrows the vault’s configured stablecoin, up to its loan-to-value limit:
src/routes.ts (continued)
openLoan, repayLoan, and liquidate must be signed by the actual borrower — CollateralVault tracks loans per msg.sender/invoker. Build a CollateralVault instance from the holder’s own signer (stellarSigner in the browser, or a per-holder stellarSecretKey server-side) rather than the platform’s admin key. See CollateralVault for the full borrower/admin method split.
5

Show the position to holders

src/components/RoyaltyPosition.tsx
Pair this with a call to GET /api/loans/:loanId to show any open loan’s live LTV alongside the position — see CollateralVault: Read Methods for getBorrowerLoans() to list all of a holder’s loan IDs.

Going further

  • Liquidation bots: anyone can call vault.liquidate(loanId) once isLiquidatable() returns true — a simple cron job that scans open loans and calls it is enough to bootstrap liquidation coverage before third-party keepers appear.
  • EVM parity: deployMiningRights() itself works identically on EVM — only the CollateralVault borrowing step in this tutorial is Stellar-specific for now.

Next steps

CollateralVault

Full reference for openLoan, repayLoan, liquidate, and every read method.

AssetRegistry

Full reference for declareRoyalty, isLicenseExpired, renewLicense.

Asset Templates

The full MiningRightsMetadata schema.

Networks

Which primitives are Stellar-only vs. available on both chains.