Skip to main content

SDK Overview

The Stablecoin Studio SDK is the core TypeScript library for issuing, managing, and operating stablecoins on Hedera. It provides a high-level abstraction over the Hedera Token Service (HTS) and the Stablecoin Studio smart contracts.


Core Methods (Write Operations)

These methods execute transactions that modify the blockchain state. They require specific roles assigned to the signer's address.

All write operations return a TransactionResult object containing:

  • success (boolean) — whether the transaction succeeded
  • transactionId (string | undefined) — the Hedera transaction ID
const result = await StableCoin.burn(request);
if (result.success) {
console.log(`Transaction ID: ${result.transactionId}`);
}
MethodMain ParametersDescriptionRequired Roles
createStableCoin(req)name, symbol, decimalsDeploys a new instance via FactoryNone (Owner)
mint(req)address, amountMints new tokens to a target accountCASHIN_ROLE
burn(req)amountBurns tokens from the treasuryBURN_ROLE
wipe(req)address, amountRemoves tokens from an account for complianceWIPE_ROLE
transfer(req)address, amountSends tokens to another addressNone
freeze(req)addressBlocks transfers for a specific accountFREEZE_ROLE
unfreeze(req)addressUnblocks a previously frozen accountFREEZE_ROLE
grantKyc(req)addressMarks an account as verifiedKYC_ROLE
revokeKyc(req)addressRevokes verification statusKYC_ROLE
pause()-Halts all operations (emergency)PAUSE_ROLE
unpause()-Resumes contract operationsPAUSE_ROLE
rescue(req)token, address, amountRecovers assets sent to the contract by mistakeRESCUE_ROLE
grantRole(req)role, addressAssigns a role to an accountDEFAULT_ADMIN_ROLE
revokeRole(req)role, addressRevokes a roleDEFAULT_ADMIN_ROLE

Query Methods (Read Operations)

State queries with no gas cost.

MethodReturnDescription
getBalance(address)BigNumberToken balance of an address
totalSupply()BigNumberTotal tokens in circulation
isFrozen(address)booleanChecks if an account is blocked
isKycPassed(address)booleanConfirms if the account has KYC

Access Control (Roles)

  • CASHIN_ROLE: Token minting
  • BURN_ROLE: Token destruction
  • WIPE_ROLE: Compliance management
  • FREEZE_ROLE: Account blocking
  • PAUSE_ROLE: Emergency pause
  • DEFAULT_ADMIN_ROLE: Master administrator

The transaction issuer must have the corresponding role or the operation will fail.


External Wallet Support

The SDK supports external wallet integrations where the private key is not passed to the SDK. Instead, the SDK serializes transactions and returns them for signing by an external system (e.g., Fireblocks, DFNS, AWS KMS, or any custodial solution).

Two wallet modes are available:

WalletDescription
EXTERNAL_HEDERAFor native Hedera Token Service (HTS) operations. Returns hex-encoded serialized Hedera transactions.
EXTERNAL_EVMFor EVM-compatible operations. Returns unsigned EVM transaction data for signing with ethers or similar libraries.

Connection

import { Network, ConnectRequest, SupportedWallets } from "@hashgraph/stablecoin-npm-sdk";

await Network.connect(
new ConnectRequest({
account: { accountId: "0.0.12345" }, // Only account ID — no private key
network: "testnet",
mirrorNode: { baseUrl: "https://testnet.mirrornode.hedera.com" },
rpcNode: { baseUrl: "https://testnet.hashio.io/api" },
wallet: SupportedWallets.EXTERNAL_HEDERA,
externalWalletSettings: {
validStartOffsetMinutes: 0,
},
})
);

Build Methods

Every write operation has a corresponding build* method that returns the raw serialized transaction without executing it. This is useful for external signing workflows or for inspecting transactions before submission.

MethodDescription
StableCoin.buildCashIn(req)Serialize a mint transaction
StableCoin.buildBurn(req)Serialize a burn transaction
StableCoin.buildWipe(req)Serialize a wipe transaction
StableCoin.buildRescue(req)Serialize a token rescue transaction
StableCoin.buildRescueHBAR(req)Serialize an HBAR rescue transaction
StableCoin.buildPause(req)Serialize a pause transaction
StableCoin.buildFreeze(req)Serialize a freeze transaction
StableCoin.buildTransfers(req)Serialize a transfer transaction

All build methods return a SerializedTransactionData object:

interface SerializedTransactionData {
serializedTransaction: string; // Hex-encoded transaction bytes
metadata: {
transactionType: string; // e.g., "ContractExecuteTransaction"
description: string; // Human-readable operation description
requiredSigners: string[]; // Account IDs that must sign
};
}
const data = await StableCoin.buildCashIn(request);
console.log(data.serializedTransaction); // Raw bytes to sign externally
console.log(data.metadata.requiredSigners); // Who needs to sign

Transaction Flow

  1. Call a build* method (e.g., StableCoin.buildBurn(request))
  2. The SDK builds and serializes the transaction but does not sign it
  3. The result includes the unsigned transaction bytes, transaction type, description, and required signers
  4. Your application signs the transaction externally and submits it to the network