Get the code
Clone the repository to follow along.
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_ROLEPrerequisites
- Clone the stablecoin-management solution
- Create a Dfns organization if you don’t have one already, and note the organization id
- Create a service account for API access (see how to create one here)
- Create the “Bank” wallet on an EVM-compatible network (e.g.: Ethereum Sepolia)
- Fund your wallet with Testnet ETH for gas fees (see using testnets)
- Make sure you have installed Node.js v18+
Project Structure
Configuration
Set up environment variables
Copy the example environment file and fill in your values:
.env
| Variable | Description |
|---|---|
DFNS_API_URL | Dfns API base URL (api.dfns.io) |
DFNS_ORG_ID | Your Dfns organization ID. See how to locate it. |
DFNS_AUTH_TOKEN | Service account auth token. Refer to creating a service account |
DFNS_CRED_ID | Credential ID for the service account signing key. Find it on the dashboard, on the Service Account page. |
DFNS_PRIVATE_KEY | Service account private key for request signing (PEM format, including the ----BEGIN/END PRIVATE KEY----) |
BANK_WALLET_ID | Wallet ID for the issuer/admin role (wa-xxxx...) |
BLOCKCHAIN_RPC_URL | RPC endpoint for the target blockchain |
Deploy
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:| Operation | Description |
|---|---|
| Pause | Halt all token transfers |
| Unpause | Resume token transfers |
| Mint | Create new tokens and send to an address |
| Burn | Destroy 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.
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.
Check the balance
Open the destination wallet in the Dfns dashboard. The token balance shows 100 bAUD.
