SettleMint
Developer guidesRunbooks

Deploy and mint a stablecoin

Create a stablecoin token with the DALP TypeScript client, configure the required roles and collateral issuer, add collateral, and mint supply.

A stablecoin needs a token contract, system roles, token roles, trusted collateral issuer status, and recorded collateral before minting. Create the stablecoin with the DALP TypeScript client. Then configure issuer and role permissions, add collateral with an expiry timestamp, and mint supply. Fiat reserve custody, treasury approval, and payment-rail settlement stay outside this API path.

Rendering diagram...

Prerequisites

Before you run the script, you need:

  1. A running DALP instance and its platform URL, such as https://your-platform.example.com.
  2. A DALP API key for the account that runs the script.
  3. A wallet PIN code configured from Account → Wallet in the DALP UI.
  4. An account with the admin role, or an administrator who can grant the required system roles and trusted issuer status.
  5. The wallet address returned by dalp.user.me({}). The script uses it when granting token roles and minting to the first holder.

Quick reference

StepWhatMethod
1Initialize ClientinitializeClient
2Get user infouserMe
3Set up roles & trusted issuerGrant tokenManager, claimPolicyManager roles
4Create stablecointokenCreate (type: "stablecoin")
5Grant token rolestokenGrantRole
6Unpause tokentokenUnpause
7Add collateraltokenUpdateCollateral
8Mint tokenstokenMint
9VerifytokenHolders

Stablecoin token lifecycle flow

The stablecoin path has one extra control before minting: collateral must be recorded by an identity trusted for the collateral claim topic.

Rendering diagram...

Stablecoin-specific requirements:

  • Trusted issuer registration: register the collateral updater as a trusted issuer for the collateral claim topic before adding collateral.
  • Collateral update: call tokenUpdateCollateral before minting stablecoin supply.
  • System roles: use tokenManager to create the token and claimPolicyManager to manage trusted issuer configuration.
  • Token roles: use supplyManagement for minting and emergency for unpausing.
  • Collateral amount: the recorded collateral must cover the minted supply under the configured collateral policy.

Step-by-step commands

Step 1: initialise the client

Initialise the DALP SDK client with your platform URL and API key.

import { createDalpClient } from "@settlemint/dalp-sdk";

async function main() {
  // Step 1: Create the SDK client
  const dalp = createDalpClient({
    url: "https://your-platform.example.com",
    apiKey: "YOUR_API_KEY",
  });
  const pincode = "YOUR_PINCODE";

  // Step 2: Get your wallet address
  const me = await dalp.user.me({});
  const myWallet = me.data.wallet;
  if (!myWallet) {
    throw new Error("No wallet found. Create a wallet first via the DALP dashboard.");
  }
  console.log("Wallet:", myWallet);

  // Step 3: Set up system roles and trusted issuer status
  // Grant yourself 'tokenManager' and 'claimPolicyManager'
  // Register as a trusted issuer for the 'collateral' claim topic

  // Step 4: Create stablecoin token
Client helper implementation details

The helper wraps common client setup:

import { createDalpClient } from "@settlemint/dalp-sdk";

// Create the SDK client — replace with your actual values
const dalp = createDalpClient({
  url: "https://your-platform.example.com",
  apiKey: "sm_dalp_xxxxxxxxxxxxxxxx",
});

// All methods are fully typed with auto-complete
const me = await dalp.user.me({});
console.log("Wallet:", me.data.wallet);

const tokens = await dalp.token.list({ query: {} });
console.log("Tokens:", tokens.data.length);

The helper handles:

  • initializeClient(baseUrl, apiKey) for one-time API authentication.
  • toBigDecimal() and fromBigDecimal() for precise numeric values.
  • SDK function re-exports so the examples can import API methods directly.

Copy src/examples/client.ts into your project if you want to reuse the same helper.


Step 2: check you're logged in

    body: {
      type: "stablecoin",
      name: "Test USD Coin",
      symbol: "TUSD",
      decimals: 18,
      countryCode: "840",
      priceCurrency: "USD",
      basePrice: "1.00",

Save the returned wallet address. Later steps use it for role grants and minting.


Step 3: set up system roles and trusted issuer status

Complete the role and issuer setup before you create the stablecoin.

  1. Grant system roles:

    • tokenManager, which allows the account to create tokens.
    • claimPolicyManager, which allows the account to manage trusted issuer configuration.
  2. Register the collateral issuer:

    • Register the identity that updates collateral as a trusted issuer for the collateral claim topic.

Only an account with the admin role can grant system roles. If your API key does not belong to an administrator, ask an administrator to grant the roles and register the trusted issuer before continuing.


Step 4: create a stablecoin token


  if ("transactionId" in stablecoin) {
    console.log("Stablecoin creation queued:", stablecoin.transactionId);
    return;
  }
  const tokenAddress = stablecoin.data.id;
  console.log("Stablecoin created:", tokenAddress);

  // Step 5: Grant token roles
  await dalp.token.grantRole({
    params: { tokenAddress },
    body: {
      accounts: [myWallet],
      role: "supplyManagement",
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },

Parameters:

  • type: set this to "stablecoin".
  • name: the token name, such as "Test USD Coin".
  • symbol: the token symbol, such as "TUSD".
  • decimals: the precision for token amounts. The example script uses 18. Use the decimal precision configured for your programme.
  • countryCode: ISO country code, such as 840 for the United States, 056 for Belgium, or 276 for Germany.
  • priceCurrency: ISO currency code for liability tracking, such as "USD", "EUR", or "GBP".
  • basePrice: the peg value for the token, such as "1.00".
  • initialModulePairs: compliance modules. The example uses [] for a basic setup.

The response returns token data with id, which is the contract address. Save it for the token role, collateral, mint, and holder calls.


Step 5: grant token roles

Grant supplyManagement for minting and emergency for unpausing on the stablecoin contract.

    },
  });
  console.log("Roles granted");

  // Step 6: Unpause the stablecoin
  await dalp.token.unpause({
    params: { tokenAddress },
    body: {
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },

Step 6: unpause the token

  console.log("Stablecoin unpaused");

  // Step 7: Add collateral (Required for stablecoins)
  const expiryDate = new Date();
  expiryDate.setFullYear(expiryDate.getFullYear() + 1);

  await dalp.token.updateCollateral({
    params: { tokenAddress },
    body: {
      amount: 1_000_000_000_000_000_000_000_000n,
      expiryTimestamp: expiryDate.toISOString(),
      walletVerification: {

Step 7: add collateral (required for stablecoins)

Stablecoin minting requires collateral first. The account that updates collateral must already be trusted for the collateral claim topic.

        verificationType: "PINCODE",
      },
    },
  });
  console.log("Collateral added");

  // Step 8: Mint stablecoins — 1000 TUSD
  await dalp.token.mint({
    params: { tokenAddress },
    body: {
      recipients: [myWallet],
      amounts: [1_000_000_000_000_000_000_000n],
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },

Parameters:

  • amount: collateral amount in the token's smallest unit. Match this to the token decimals you configured.
  • expiryTimestamp: ISO 8601 timestamp for when the collateral claim expires.

The call returns token data with updated collateral. If DALP reports that the caller is not a trusted issuer, complete the trusted issuer setup for the collateral claim topic before retrying.


Step 8: mint stablecoins

  console.log("Minted stablecoins");

  // Step 9: Verify holders
  const holders = await dalp.token.holders({ params: { tokenAddress }, query: { limit: 200 } });
  console.log("Holders:", holders.data);
}

await main();

Parameters:

  • contract: the stablecoin contract address.
  • recipients: recipient wallet addresses.
  • amounts: amounts in the token's smallest unit. For the 18-decimal example script, 1_000_000_000_000_000_000_000n represents 1,000 tokens.

The call returns token data with updated totalSupply.


Step 9: verify the mint

The holder query returns wallets and balances for the token.


Full script

Replace YOUR_PLATFORM_URL, YOUR_API_KEY, and YOUR_PINCODE in the complete script before you run it.

Important:

  • Step 3 in the script is a placeholder because role and trusted issuer setup is an administrative action.
  • Complete the tokenManager, claimPolicyManager, and collateral trusted issuer setup before you continue.
  • If you do not have admin access, ask an administrator to complete those setup steps.
import { createDalpClient } from "@settlemint/dalp-sdk";

async function main() {
  // Step 1: Create the SDK client
  const dalp = createDalpClient({
    url: "https://your-platform.example.com",
    apiKey: "YOUR_API_KEY",
  });
  const pincode = "YOUR_PINCODE";

  // Step 2: Get your wallet address
  const me = await dalp.user.me({});
  const myWallet = me.data.wallet;
  if (!myWallet) {
    throw new Error("No wallet found. Create a wallet first via the DALP dashboard.");
  }
  console.log("Wallet:", myWallet);

  // Step 3: Set up system roles and trusted issuer status
  // Grant yourself 'tokenManager' and 'claimPolicyManager'
  // Register as a trusted issuer for the 'collateral' claim topic

  // Step 4: Create stablecoin token
  const stablecoin = await dalp.token.create({
    body: {
      type: "stablecoin",
      name: "Test USD Coin",
      symbol: "TUSD",
      decimals: 18,
      countryCode: "840",
      priceCurrency: "USD",
      basePrice: "1.00",
      initialModulePairs: [],
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });

  if ("transactionId" in stablecoin) {
    console.log("Stablecoin creation queued:", stablecoin.transactionId);
    return;
  }
  const tokenAddress = stablecoin.data.id;
  console.log("Stablecoin created:", tokenAddress);

  // Step 5: Grant token roles
  await dalp.token.grantRole({
    params: { tokenAddress },
    body: {
      accounts: [myWallet],
      role: "supplyManagement",
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });
  await dalp.token.grantRole({
    params: { tokenAddress },
    body: {
      accounts: [myWallet],
      role: "emergency",
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });
  console.log("Roles granted");

  // Step 6: Unpause the stablecoin
  await dalp.token.unpause({
    params: { tokenAddress },
    body: {
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });
  console.log("Stablecoin unpaused");

  // Step 7: Add collateral (Required for stablecoins)
  const expiryDate = new Date();
  expiryDate.setFullYear(expiryDate.getFullYear() + 1);

  await dalp.token.updateCollateral({
    params: { tokenAddress },
    body: {
      amount: 1_000_000_000_000_000_000_000_000n,
      expiryTimestamp: expiryDate.toISOString(),
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });
  console.log("Collateral added");

  // Step 8: Mint stablecoins — 1000 TUSD
  await dalp.token.mint({
    params: { tokenAddress },
    body: {
      recipients: [myWallet],
      amounts: [1_000_000_000_000_000_000_000n],
      walletVerification: {
        secretVerificationCode: pincode,
        verificationType: "PINCODE",
      },
    },
  });
  console.log("Minted stablecoins");

  // Step 9: Verify holders
  const holders = await dalp.token.holders({ params: { tokenAddress }, query: { limit: 200 } });
  console.log("Holders:", holders.data);
}

await main();

Common country codes

  • 840 = USA
  • 056 = Belgium
  • 276 = Germany
  • 826 = UK
  • 392 = Japan

Amount calculations

DALP expects mint and collateral amounts in the token's smallest unit. Use:

token amount * 10^decimals

For a 6-decimal token:

  • 1 token = 1 * 10^6 = 1000000
  • 1,000 tokens = 1000 * 10^6 = 1000000000

For the 18-decimal token in the example script:

  • 1 token = 1 * 10^18 = 1000000000000000000
  • 1,000 tokens = 1000 * 10^18 = 1000000000000000000000

Stablecoin listing with collateral information

Troubleshooting

"Authentication missing": check the API key passed to initializeClient.

"PINCODE_INVALID": reconfirm the PIN from Account → Wallet (/account/wallet).

"USER_NOT_AUTHORIZED" or "tokenManager required": grant the tokenManager role. This requires admin access.

"Permission denied": grant the required token roles, such as supplyManagement or emergency.

"Token is paused": make sure Step 6 succeeded and the caller has the emergency role.

"InsufficientCollateral": make sure Step 7 succeeded and the collateral amount covers the mint amount under the configured policy.

"You are not a trusted issuer for topic(s): collateral": register the collateral updater as a trusted issuer for the collateral claim topic.

"RecipientNotVerified": the recipient wallet needs an identity before it can receive tokens. Register the identity with systemIdentityCreate.

jq is optional for local scripting. Install it with brew install jq on macOS or apt install jq on Linux if you want to parse JSON responses in shell commands.

On this page