Deploy and Mint a Stablecoin via API

Step-by-step guide for creating and minting stablecoin tokens using the ATK REST API

PREREQUISITES

Before running these commands, you need to:

  1. Platform URL - Know your ATK platform URL (e.g., https://your-platform.example.com)
  2. Deploy ATK - Have a running ATK instance (local or hosted)
  3. Sign up - Create a user account through the ATK UI with email/password
  4. Enable PINCODE - Set up PINCODE in Account Settings → Security (YOUR_PLATFORM_URL/account/profile)
  5. Admin role - Your account must have admin role 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

StepWhatEndpoint
1Sign inPOST /api/auth/sign-in/email
2Get user infoGET /api/user/me
3Set up roles & trusted issuerSee Set Up Roles guide
4Create stablecoinPOST /api/token/create (type: "stablecoin")
5Grant token rolesSee Set Up Roles guide
6Unpause tokenPOST /api/token/{contract}/unpause
7Add collateralPOST /api/token/{contract}/update-collateral
8Mint tokensPOST /api/token/{contract}/mint
9VerifyGET /api/token/{contract}/holders

STEP-BY-STEP COMMANDS

Step 1: sign in

curl -v -X POST YOUR_PLATFORM_URL/api/auth/sign-in/email \
  -H "Content-Type: application/json" \
  -c cookies.txt \
  -d '{
    "email": "YOUR_EMAIL",
    "password": "YOUR_PASSWORD"
  }'

Expected: Status 200 OK, cookie saved to cookies.txt


Step 2: check you're logged in

curl -s YOUR_PLATFORM_URL/api/user/me \
  -b cookies.txt | jq '.'

Expected: JSON with your user info, wallet address, pincodeEnabled: true

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:

  1. Grant system roles (Step 2 in that guide):

    • tokenManager - Required to create tokens
    • claimPolicyManager - Required to register as a trusted issuer
  2. Register as trusted issuer (Step 3 in that guide):

    • Register your identity for the collateral claim topic

Those sections in the roles guide include the full POST /api/system/access-manager/grant-roles and POST /api/system/trusted-issuers payloads—copy them 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

curl -v -X POST YOUR_PLATFORM_URL/api/token/create \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "type": "stablecoin",
    "name": "Test USD Coin",
    "symbol": "TUSD",
    "decimals": 6,
    "countryCode": 840,
    "basePrice": "1.00",
    "initialModulePairs": [],
    "walletVerification": {
      "secretVerificationCode": "YOUR_PINCODE",
      "verificationType": "PINCODE"
    }
  }'

Parameters:

  • type: Must be "stablecoin"
  • name: Token name (e.g., "Test USD Coin")
  • symbol: Token symbol (e.g., "TUSD")
  • decimals: Usually 6 for stablecoins (like USDC) or 18
  • countryCode: ISO country code (840 = USA, 056 = Belgium, 276 = Germany)
  • basePrice: Token peg value as a string (e.g., "1.00" = $1.00)
  • initialModulePairs: Compliance modules (empty array [] for basic setup)
  • walletVerification.secretVerificationCode: Your PINCODE
  • walletVerification.verificationType: Always "PINCODE"

Expected: Status 200 OK, 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.

Follow the Set Up Roles guide Step 4 to grant these roles. Use your stablecoin contract address from Step 4.


Step 6: unpause the token

curl -v -X POST YOUR_PLATFORM_URL/api/token/YOUR_CONTRACT_ADDRESS/unpause \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "contract": "YOUR_CONTRACT_ADDRESS",
    "walletVerification": {
      "secretVerificationCode": "YOUR_PINCODE",
      "verificationType": "PINCODE"
    }
  }'

Replace:

  • YOUR_CONTRACT_ADDRESS: The stablecoin contract address

Expected: Status 200 OK


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).

curl -v -X POST YOUR_PLATFORM_URL/api/token/YOUR_CONTRACT_ADDRESS/update-collateral \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "contract": "YOUR_CONTRACT_ADDRESS",
    "amount": "1000000000000",
    "expiryTimestamp": "2026-12-31T23:59:59Z",
    "walletVerification": {
      "secretVerificationCode": "YOUR_PINCODE",
      "verificationType": "PINCODE"
    }
  }'

Replace:

  • YOUR_CONTRACT_ADDRESS: The stablecoin contract address
  • amount: Collateral amount in smallest unit (e.g., "1000000000000" = 1,000,000 tokens with 6 decimals)
  • expiryTimestamp: Future date when collateral expires (ISO 8601 format)

Expected: Status 200 OK, 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 3 to register as a trusted issuer for the collateral claim topic.


Step 8: mint stablecoins!

curl -v -X POST YOUR_PLATFORM_URL/api/token/YOUR_CONTRACT_ADDRESS/mint \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d '{
    "contract": "YOUR_CONTRACT_ADDRESS",
    "recipients": ["YOUR_RECIPIENT_WALLET"],
    "amounts": ["1000000"],
    "walletVerification": {
      "secretVerificationCode": "YOUR_PINCODE",
      "verificationType": "PINCODE"
    }
  }'

Parameters:

  • contract: Your stablecoin contract address
  • recipients: 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)
  • walletVerification.secretVerificationCode: Your PINCODE
  • walletVerification.verificationType: Always "PINCODE"

Expected: Status 200 OK, returns token data with updated totalSupply


Step 9: verify the mint

curl -s YOUR_PLATFORM_URL/api/token/YOUR_CONTRACT_ADDRESS/holders?tokenAddress=YOUR_CONTRACT_ADDRESS \
  -b cookies.txt | jq '.'

Expected: Shows token holders with their balances


FULL SCRIPT

Replace the variables at the top and run:

Note: This script references the Set Up Roles guide for role management. It assumes you have admin role to grant system roles. If you don't have admin access, you'll need your system administrator to grant you the tokenManager and claimPolicyManager roles, and register you as a trusted issuer for collateral.

#!/bin/bash

# ============================================
# YOUR VALUES (CONFIGURED)
# ============================================
EMAIL="YOUR_EMAIL"
PASSWORD="YOUR_PASSWORD"
PINCODE="YOUR_PINCODE"
RECIPIENT="YOUR_WALLET_ADDRESS"  # Replace with your wallet from Step 2
BASE_URL="YOUR_PLATFORM_URL"

# ============================================
# COMMANDS (DO NOT EDIT BELOW)
# ============================================

echo "Step 1: Signing in..."
curl -s -X POST $BASE_URL/api/auth/sign-in/email \
  -H "Content-Type: application/json" \
  -c cookies.txt \
  -d "{\"email\":\"$EMAIL\",\"password\":\"$PASSWORD\"}" > /dev/null

echo " Signed in"
echo ""

echo "Step 2: Getting user info..."
USER_INFO=$(curl -s $BASE_URL/api/user/me -b cookies.txt)
WALLET=$(echo $USER_INFO | jq -r '.wallet')
echo " Your wallet: $WALLET"
echo ""

echo "Step 3: Set up system roles and trusted issuer..."
echo " Follow the Set Up Roles guide to:"
echo "   1. Grant tokenManager and claimPolicyManager system roles (Step 2)"
echo "   2. Register as trusted issuer for collateral (Step 3)"
echo " See: /developer-guides/api-integration/set-up-roles"
echo ""

echo "Step 4: Creating stablecoin token..."
CREATE_RESPONSE=$(curl -s -X POST $BASE_URL/api/token/create \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d "{\"type\":\"stablecoin\",\"name\":\"Test USD Coin\",\"symbol\":\"TUSD\",\"decimals\":6,\"countryCode\":840,\"basePrice\":\"1.00\",\"initialModulePairs\":[],\"walletVerification\":{\"secretVerificationCode\":\"$PINCODE\",\"verificationType\":\"PINCODE\"}}")

CONTRACT=$(echo $CREATE_RESPONSE | jq -r '.id')
echo " Stablecoin created: $CONTRACT"
echo ""

echo "Step 5: Grant token roles..."
echo " Follow the Set Up Roles guide Step 4 to grant supplyManagement and emergency roles"
echo " See: /developer-guides/api-integration/set-up-roles"
echo ""

echo "Step 6: Unpausing token..."
curl -s -X POST $BASE_URL/api/token/$CONTRACT/unpause \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d "{\"contract\":\"$CONTRACT\",\"walletVerification\":{\"secretVerificationCode\":\"$PINCODE\",\"verificationType\":\"PINCODE\"}}" > /dev/null
echo " Token unpaused"
echo ""

echo "Step 7: Adding collateral..."
# Calculate expiry timestamp (1 year from now)
EXPIRY=$(date -u -v+1y +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -d "+1 year" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "2026-12-31T23:59:59Z")
curl -s -X POST $BASE_URL/api/token/$CONTRACT/update-collateral \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d "{\"contract\":\"$CONTRACT\",\"amount\":\"1000000000000\",\"expiryTimestamp\":\"$EXPIRY\",\"walletVerification\":{\"secretVerificationCode\":\"$PINCODE\",\"verificationType\":\"PINCODE\"}}" > /dev/null
echo " Collateral added"
echo ""

echo "Step 8: Minting 1000 TUSD..."
MINT_RESPONSE=$(curl -s -X POST $BASE_URL/api/token/$CONTRACT/mint \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -d "{\"contract\":\"$CONTRACT\",\"recipients\":[\"$RECIPIENT\"],\"amounts\":[\"1000000000\"],\"walletVerification\":{\"secretVerificationCode\":\"$PINCODE\",\"verificationType\":\"PINCODE\"}}")

echo " Minted!"
echo ""
echo "Response:"
echo $MINT_RESPONSE | jq '.'
echo ""

echo "Step 9: Checking holders..."
curl -s $BASE_URL/api/token/$CONTRACT/holders?tokenAddress=$CONTRACT -b cookies.txt | jq '.token.balances'

echo ""
echo "DONE! Stablecoin minted successfully!"
echo "Contract: $CONTRACT"
echo "View on explorer: YOUR_EXPLORER_URL"

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" → Check your PINCODE in /account/profile

"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 3 to register as a trusted issuer for the collateral claim topic

Need jq? Install with: brew install jq (Mac) or apt install jq (Linux)