IHTSAdapter
Title: IHTSAdapter
Author: Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)
Interface for the HTSAdapter Diamond facet — the diamond as a Hedera Token Service account: it
associates itself with HTS tokens, moves its own balances, and creates / mints / burns tokens
whose supply and admin keys are held by the diamond (as delegatableContractId keys).
Every HTS system-contract call returns an int64 response code instead of reverting; the facet maps
the common codes to the typed errors below and everything else to HTSCallFailed. Amounts are
int64 and NFT serials are int64, exactly as HTS defines them.
Functions
isAssociated
True if the diamond is associated with token (HIP-719 facade isAssociated()).
function isAssociated(address token) external view returns (bool associated);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| associated | bool |
isHTSToken
True if token is an HTS token (isToken on the system contract).
function isHTSToken(address token) external view returns (bool isToken);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| isToken | bool |
htsTokenType
HTS token type: 0 fungible, 1 non-fungible.
function htsTokenType(address token) external view returns (int32 tokenType);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
Returns
| Name | Type | Description |
|---|---|---|
| tokenType | int32 |
createdTokens
The HTS tokens this diamond created (it is their treasury and key holder).
function createdTokens() external view returns (address[] memory tokens);Returns
| Name | Type | Description |
|---|---|---|
| tokens | address[] |
associateToken
Associates the diamond with token so it can hold and receive it.
function associateToken(address token) external;Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
dissociateToken
Dissociates the diamond from token (its balance must be zero).
function dissociateToken(address token) external;Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
createFungibleToken
Creates a fungible HTS token with the diamond as treasury, auto-renew account, and holder of the
admin + supply keys (delegatableContractId). msg.value pays the network's creation fee.
function createFungibleToken(
string calldata name,
string calldata symbol,
string calldata memo,
int32 decimals,
int64 initialSupply,
int64 maxSupply
) external payable returns (address token);Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| symbol | string | |
| memo | string | |
| decimals | int32 | |
| initialSupply | int64 | |
| maxSupply | int64 | Zero for an infinite supply; otherwise the finite cap. |
Returns
| Name | Type | Description |
|---|---|---|
| token | address |
createNonFungibleToken
Creates a non-fungible HTS token with the diamond as treasury / key holder. msg.value pays the fee.
function createNonFungibleToken(string calldata name, string calldata symbol, string calldata memo, int64 maxSupply)
external
payable
returns (address token);Parameters
| Name | Type | Description |
|---|---|---|
| name | string | |
| symbol | string | |
| memo | string | |
| maxSupply | int64 |
Returns
| Name | Type | Description |
|---|---|---|
| token | address |
transferToken
Transfers amount of token from the diamond's own balance to to.
function transferToken(address token, address to, int64 amount) external;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| to | address | |
| amount | int64 |
transferTokenFrom
Transfers amount of token from from to to using the allowance from granted the diamond.
function transferTokenFrom(address token, address from, address to, int64 amount) external;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| from | address | |
| to | address | |
| amount | int64 |
transferNFT
Transfers NFT serialNumber of token owned by the diamond to to.
function transferNFT(address token, address to, int64 serialNumber) external;Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| to | address | |
| serialNumber | int64 |
mintToken
Mints amount units (FT) or metadata.length serials (NFT) to the treasury. Requires the diamond
to hold the supply key as a delegatableContractId key.
function mintToken(address token, int64 amount, bytes[] calldata metadata)
external
returns (int64 newTotalSupply, int64[] memory serialNumbers);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| amount | int64 | |
| metadata | bytes[] |
Returns
| Name | Type | Description |
|---|---|---|
| newTotalSupply | int64 | |
| serialNumbers | int64[] |
burnToken
Burns amount units (FT) or the given serialNumbers (NFT) from the treasury.
function burnToken(address token, int64 amount, int64[] calldata serialNumbers)
external
returns (int64 newTotalSupply);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| amount | int64 | |
| serialNumbers | int64[] |
Returns
| Name | Type | Description |
|---|---|---|
| newTotalSupply | int64 |
Events
HTSTokenAssociated
Emitted when the diamond associates itself with token.
event HTSTokenAssociated(address indexed token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSTokenDissociated
Emitted when the diamond dissociates itself from token.
event HTSTokenDissociated(address indexed token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSTokenCreated
Emitted when the diamond creates an HTS token (it is the treasury and key holder).
event HTSTokenCreated(address indexed token, bool fungible);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| fungible | bool |
HTSTokenTransferred
Emitted on a successful HTS transfer initiated by the diamond.
event HTSTokenTransferred(address indexed token, address indexed from, address indexed to, int64 amount);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| from | address | |
| to | address | |
| amount | int64 |
HTSTokenMinted
Emitted after a successful mint (amount is units for FT, number of serials for NFT).
event HTSTokenMinted(address indexed token, int64 amount, int64 newTotalSupply);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| amount | int64 | |
| newTotalSupply | int64 |
HTSTokenBurned
Emitted after a successful burn.
event HTSTokenBurned(address indexed token, int64 amount, int64 newTotalSupply);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| amount | int64 | |
| newTotalSupply | int64 |
Errors
HTSTokenNotAssociated
account is not associated with token (HTS 184).
error HTSTokenNotAssociated(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSTokenAlreadyAssociated
account is already associated with token (HTS 194).
error HTSTokenAlreadyAssociated(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSInsufficientBalance
account holds too little of token (HTS 178 / 28).
error HTSInsufficientBalance(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSNonZeroBalance
account still holds a balance of token, so it cannot be dissociated (HTS 195).
error HTSNonZeroBalance(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSAccountIsTreasury
account is token's treasury, so it can never be dissociated from it (HTS 196).
error HTSAccountIsTreasury(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSKeyNotActive
No active key authorized the operation (HTS 7 / 326). For a diamond the usual cause is a token
key set as contractId instead of delegatableContractId: a facet reaches HTS inside a
delegatecall frame, where a contractId key is refused wherever it is verified. Note this
error is NOT what you get for a contractId(<diamond>) key on a relay-deployed diamond —
that key is byte-identical to the diamond's own account key, which is the dispatched child's
payer key, so it is elided before verification and the call succeeds. Measured on testnet
2026-09-12; see docs/guides/hedera.md.
error HTSKeyNotActive(address token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSTokenNoSupplyKey
token has no supply key (HTS 180).
error HTSTokenNoSupplyKey(address token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSMaxSupplyReached
The mint would exceed token's max supply (HTS 236).
error HTSMaxSupplyReached(address token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSTokenPaused
token is paused (HTS 265).
error HTSTokenPaused(address token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSAccountFrozen
account is frozen for token (HTS 165).
error HTSAccountFrozen(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSKycNotGranted
account has no KYC grant for token (HTS 176).
error HTSKycNotGranted(address token, address account);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| account | address |
HTSAllowanceExceeded
The diamond's allowance from owner on token is missing or too small (HTS 292 / 293).
error HTSAllowanceExceeded(address token, address owner);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| owner | address |
HTSInsufficientGas
The frame did not carry enough gas for the system-contract fee (HTS 30).
error HTSInsufficientGas();HTSNotAToken
token is not an HTS token (HTS 167 / isToken false).
error HTSNotAToken(address token);Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
HTSInvalidAmount
An amount, serial list, or supply parameter was invalid (HTS 182 / 183 / 225 or local check).
error HTSInvalidAmount();HTSCallFailed
Catch-all: HTS function selector returned responseCode.
error HTSCallFailed(bytes4 selector, int64 responseCode);Parameters
| Name | Type | Description |
|---|---|---|
| selector | bytes4 | |
| responseCode | int64 |