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
MiningRightsTokenper 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
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)
5
Show the position to holders
src/components/RoyaltyPosition.tsx
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)onceisLiquidatable()returnstrue— 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 theCollateralVaultborrowing 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.