Skip to main content
Deploy and manage an ERC-20 stablecoin with mint, burn, and pause controls — all transactions signed and broadcast through Dfns managed wallets.

Get the code

Clone the repository to follow along.
Stablecoin issuers need to deploy a token contract, mint and burn supply, and freeze transfers in emergencies — all while keeping signing keys secure. This solution blueprint shows how to do that with Dfns wallets handling the key management and transaction signing. The StableCoin contract supports:

Minting

Create tokens and send to any address

Burning

Destroy tokens from the caller’s balance

Pausing

Halt all token transfers (emergency controls)

Role-based access

Restrict minting to authorized addresses via MINTER_ROLE

Prerequisites

  1. Clone the stablecoin-management solution
  2. Create a Dfns organization if you don’t have one already, and note the organization id
  3. Create a service account for API access (see how to create one here)
  4. Create the “Bank” wallet on an EVM-compatible network (e.g.: Ethereum Sepolia)
  5. Fund your wallet with Testnet ETH for gas fees (see using testnets)
  6. Make sure you have installed Node.js v18+

Project Structure

contracts/
  StableCoin.sol       ERC-20 stablecoin with mint, burn, pause, and role-based access

dfns/
  DfnsCommon.ts        Shared Dfns API client and blockchain configuration
  DeployStableCoin.ts  Deploy a stablecoin contract
  StableCoinOps.ts     Interactive CLI for stablecoin operations

Configuration

1

Clone and install

cd stablecoin-management
npm install
2

Set up environment variables

Copy the example environment file and fill in your values:
cp .env.example .env
.env
# Dfns API Configuration
DFNS_API_URL=https://api.dfns.io
DFNS_ORG_ID=or-xxx-xxx
DFNS_AUTH_TOKEN=eyJ...
DFNS_CRED_ID=xxx
DFNS_PRIVATE_KEY="-----BEGIN EC PRIVATE KEY-----\n...\n-----END EC PRIVATE KEY-----"

# Dfns Wallet IDs
BANK_WALLET_ID=wa-xxx-xxx

# Blockchain Configuration
BLOCKCHAIN_RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
VariableDescription
DFNS_API_URLDfns API base URL (api.dfns.io)
DFNS_ORG_IDYour Dfns organization ID. See how to locate it.
DFNS_AUTH_TOKENService account auth token. Refer to creating a service account
DFNS_CRED_IDCredential ID for the service account signing key. Find it on the dashboard, on the Service Account page.
DFNS_PRIVATE_KEYService account private key for request signing (PEM format, including the ----BEGIN/END PRIVATE KEY----)
BANK_WALLET_IDWallet ID for the issuer/admin role (wa-xxxx...)
BLOCKCHAIN_RPC_URLRPC endpoint for the target blockchain
3

Compile contracts

npx hardhat compile

Deploy

npm run deploy
This deploys a StableCoin contract called “Bank AUD” (bAUD) with the Bank wallet as owner. The script outputs the deployed contract address.

Manage with the Operations CLI

Use the interactive CLI to manage the deployed stablecoin:
npm run ops <contractAddress>
The CLI provides these operations:
OperationDescription
PauseHalt all token transfers
UnpauseResume token transfers
MintCreate new tokens and send to an address
BurnDestroy tokens from the caller’s balance

Example: mint, verify, burn

This walkthrough mints 100 bAUD to a destination wallet, checks the balance, burns tokens from the Bank wallet, and verifies the updated balance. The token uses 6 decimals, so 100 tokens = 100000000.
1

Create a destination wallet

Create a new wallet on the same network as the stablecoin contract. This wallet will receive the minted tokens. Copy its address from the dashboard.
2

Mint 100 bAUD

Run the CLI and select Mint, using the destination wallet address as the recipient:
npm run ops 0xYourContractAddress
--- Smart Contract Operations ---
1. Pause
2. Unpause
3. Mint
4. Burn
5. Exit
Select an operation (1-5): 3
Enter recipient address: 0xDestinationWalletAddress
Enter amount to mint: 100000000
Broadcasting transaction...
Transaction broadcasted successfully!
Transaction Hash: 0x...
Status: Broadcasted
3

Check the balance

Open the destination wallet in the Dfns dashboard. The token balance shows 100 bAUD.