Deploy and Mint a Stablecoin using the TypeScript Client
Step-by-step guide for creating and minting stablecoin tokens using the ATK TypeScript Client
PREREQUISITES
Before running these commands, you need to:
- Platform URL - Know your ATK platform URL (e.g.,
https://your-platform.example.com) - Deploy ATK - Have a running ATK instance (local or hosted)
- Sign up - Create a user account through the ATK UI with email/password
- Enable PINCODE - Set up PINCODE during onboarding. Manage it from Account → Wallet.
- Admin role - Your account must have
adminrole to grant system roles (Steps 3a and 3d)
Note: Your wallet address is available via ATK while signing up, or you can get it from Step 2. You'll need it for Steps 3a, 3d, 5, and 8.
Quick reference
| Step | What | Method |
|---|---|---|
| 1 | Initialize Client | createClient |
| 2 | Get user info | client.user.me |
| 3 | Set up roles & trusted issuer | See Set Up Roles guide |
| 4 | Create stablecoin | client.token.create (type: "stablecoin") |
| 5 | Grant token roles | See Set Up Roles guide |
| 6 | Unpause token | client.token.unpause |
| 7 | Add collateral | client.token.updateCollateral |
| 8 | Mint tokens | client.token.mint |
| 9 | Verify | client.token.holders |
STEP-BY-STEP COMMANDS
Step 1: Initialize Client
Initialize the ORPC client with your platform URL and authentication token.
Client helper implementation details
Here's what the helper does behind the scenes:
Why use the helper? It handles:
- ✅ 7 imports from different packages (
@orpc/client,@orpc/client/fetch,@atk/zod/*,@orpc/server, router types) - ✅ Configuring 3 custom JSON serializers (
bigDecimalSerializer,bigIntSerializer,timestampSerializer) - ✅ Setting up the
RPCLinkwith proper headers - ✅ Type-safe client creation
If you don't have the helper file, you'll need to set it up manually (not recommended):
import { createORPCClient } from "@orpc/client";
import { RPCLink } from "@orpc/client/fetch";
import { bigDecimalSerializer } from "@atk/zod/bigdecimal";
import { bigIntSerializer } from "@atk/zod/bigint";
import { timestampSerializer } from "@atk/zod/timestamp";
import type { RouterClient } from "@orpc/server";
import type { router } from "@/orpc/routes/router";
const link = new RPCLink({
url: "https://your-platform.example.com/api/rpc",
headers: () => ({
"x-api-key": `YOUR_API_KEY_TOKEN`,
}),
customJsonSerializers: [bigDecimalSerializer, bigIntSerializer, timestampSerializer],
});
const client: RouterClient<typeof router> = createORPCClient(link);💡 Tip: Copy the client.ts file from src/examples/client.ts to your project to use the helper!
Step 2: check you're logged in
Save your wallet address - you'll need it!
Step 3: set up system roles and trusted issuer status
REQUIRED: Complete these steps to grant yourself the necessary system roles and register as a trusted issuer for collateral.
Follow the Set Up Roles guide:
-
Grant system roles :
tokenManager- Required to create tokensclaimPolicyManager- Required to register as a trusted issuer
-
Register as trusted issuer
- Register your identity for the
collateralclaim topic
- Register your identity for the
Those sections in the roles guide include the full TypeScript client calls—copy the code snippets directly to satisfy this step.
Note: Only users with admin role can grant system roles. If you don't have admin access, ask your system administrator to grant you these roles and register you as a trusted issuer.
Step 4: create a stablecoin token
Parameters:
type: Must be"stablecoin"name: Token name (e.g., "Test USD Coin")symbol: Token symbol (e.g., "TUSD")decimals: Usually6for stablecoins (like USDC) or18countryCode: ISO country code (840 = USA, 056 = Belgium, 276 = Germany)priceCurrency: ISO currency code for liability tracking (e.g., "USD", "EUR", "GBP")basePrice: Token peg value usingfrom(value, precision)helper- Example:
from("1.00", 2)= $1.00 with 2 decimal precision - Used with
priceCurrencyfor liability tracking dashboards
- Example:
initialModulePairs: Compliance modules (empty array[]for basic setup)
Expected: Returns token data with id (contract address)
SAVE THE CONTRACT ADDRESS from the response! You need it for Step 5.
Step 5: grant token roles
REQUIRED: Grant yourself supplyManagement (for minting) and emergency (for unpausing) roles on the stablecoin contract.
Step 6: unpause the token
Step 7: add collateral (required for stablecoins)
IMPORTANT: Stablecoins require collateral before minting. You must complete Step 3 first to register as a trusted issuer for the collateral claim topic (see Set Up Roles guide Step 4).
Parameters:
amount: Collateral amount in smallest unit (e.g.,1000000000000n= 1,000,000 tokens with 6 decimals)expiryTimestamp: Future date when collateral expires
Expected: Returns token data with updated collateral
Note: If you get an error about not being a trusted issuer, follow the Set Up Roles guide Step 4 to register as a trusted issuer for the collateral claim topic.
Step 8: mint stablecoins
Parameters:
contract: Your stablecoin contract addressrecipients: Array with recipient wallet address(es)amounts: Array with amounts in smallest unit- To mint X tokens with 6 decimals, use:
X * 10^6 - Example:
1 * 10^6= 1 TUSD - Example:
1000 * 10^6= 1000 TUSD - For 18 decimals:
X * 10^18(e.g.,1 * 10^18= 1 token)
- To mint X tokens with 6 decimals, use:
Expected: Returns token data with updated totalSupply
Step 9: verify the mint
Expected: Shows token holders with their balances
FULL SCRIPT
Complete working script - Replace the variables at the top (YOUR_PLATFORM_URL, YOUR_AUTH_TOKEN, YOUR_PINCODE) and run:
Important:
- This script references the Set Up Roles guide for Step 3 (role management)
- Step 3 in the script is a placeholder comment—you must complete the role setup steps manually before continuing
- It assumes you have
adminrole to grant system roles. If you don't have admin access, you'll need your system administrator to grant you thetokenManagerandclaimPolicyManagerroles, and register you as a trusted issuer for collateral
Common country codes
- 840 = USA
- 056 = Belgium
- 276 = Germany
- 826 = UK
- 392 = Japan
Amount calculations
For stablecoins with 6 decimals (like USDC), use the formula: amount * 10^6
Examples:
- 1 TUSD =
1 * 10^6=1000000 - 10 TUSD =
10 * 10^6=10000000 - 100 TUSD =
100 * 10^6=100000000 - 1000 TUSD =
1000 * 10^6=1000000000
For tokens with 18 decimals, use the formula: amount * 10^18
Examples:
- 1 token =
1 * 10^18=1000000000000000000 - 10 tokens =
10 * 10^18=10000000000000000000
To mint X tokens, calculate: X * 10^decimals (where decimals = 6 for stablecoins like USDC, or 18 for other tokens)
Troubleshooting
"Authentication missing" → Run Step 1 again (sign in)
"PINCODE_INVALID" → Reconfirm the PIN from Account → Wallet (/account/wallet)
"USER_NOT_AUTHORIZED" / "tokenManager required" → Follow the Set Up Roles guide Step 2 to grant the tokenManager system role
"Permission denied" → Follow the Set Up Roles guide Step 4 to grant token roles
"Token is paused" → Make sure Step 6 (unpause) succeeded and you have emergency role
"InsufficientCollateral" → Make sure Step 7 (add collateral) succeeded. You must be a trusted issuer for the collateral claim topic.
"You are not a trusted issuer for topic(s): collateral" → Follow the Set Up Roles guide Step 4 to register as a trusted issuer for the collateral claim topic
"RecipientNotVerified" → Your wallet needs an identity registered before it can receive tokens. Follow the Set Up Roles guide Step 3 to register your identity.
Need jq? Install with: brew install jq (Mac) or apt install jq (Linux)
Deploy and Mint a Fund using the TypeScript Client
Step-by-step guide for creating and minting fund tokens using the ATK TypeScript Client
Data model overview
The Asset Tokenization Kit employs a dual-layer data architecture that combines off-chain PostgreSQL storage with on-chain TheGraph indexing. This hybrid approach delivers fast user experiences while maintaining an immutable audit trail of all blockchain state changes, enabling both real-time operational queries and comprehensive historical analysis.