Skip to content
Lattice

IHTSAdapter

Git Source

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

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
associatedbool

isHTSToken

True if token is an HTS token (isToken on the system contract).

function isHTSToken(address token) external view returns (bool isToken);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
isTokenbool

htsTokenType

HTS token type: 0 fungible, 1 non-fungible.

function htsTokenType(address token) external view returns (int32 tokenType);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
tokenTypeint32

createdTokens

The HTS tokens this diamond created (it is their treasury and key holder).

function createdTokens() external view returns (address[] memory tokens);

Returns

NameTypeDescription
tokensaddress[]

associateToken

Associates the diamond with token so it can hold and receive it.

function associateToken(address token) external;

Parameters

NameTypeDescription
tokenaddress

dissociateToken

Dissociates the diamond from token (its balance must be zero).

function dissociateToken(address token) external;

Parameters

NameTypeDescription
tokenaddress

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

NameTypeDescription
namestring
symbolstring
memostring
decimalsint32
initialSupplyint64
maxSupplyint64Zero for an infinite supply; otherwise the finite cap.

Returns

NameTypeDescription
tokenaddress

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

NameTypeDescription
namestring
symbolstring
memostring
maxSupplyint64

Returns

NameTypeDescription
tokenaddress

transferToken

Transfers amount of token from the diamond's own balance to to.

function transferToken(address token, address to, int64 amount) external;

Parameters

NameTypeDescription
tokenaddress
toaddress
amountint64

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

NameTypeDescription
tokenaddress
fromaddress
toaddress
amountint64

transferNFT

Transfers NFT serialNumber of token owned by the diamond to to.

function transferNFT(address token, address to, int64 serialNumber) external;

Parameters

NameTypeDescription
tokenaddress
toaddress
serialNumberint64

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

NameTypeDescription
tokenaddress
amountint64
metadatabytes[]

Returns

NameTypeDescription
newTotalSupplyint64
serialNumbersint64[]

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

NameTypeDescription
tokenaddress
amountint64
serialNumbersint64[]

Returns

NameTypeDescription
newTotalSupplyint64

Events

HTSTokenAssociated

Emitted when the diamond associates itself with token.

event HTSTokenAssociated(address indexed token);

Parameters

NameTypeDescription
tokenaddress

HTSTokenDissociated

Emitted when the diamond dissociates itself from token.

event HTSTokenDissociated(address indexed token);

Parameters

NameTypeDescription
tokenaddress

HTSTokenCreated

Emitted when the diamond creates an HTS token (it is the treasury and key holder).

event HTSTokenCreated(address indexed token, bool fungible);

Parameters

NameTypeDescription
tokenaddress
fungiblebool

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

NameTypeDescription
tokenaddress
fromaddress
toaddress
amountint64

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

NameTypeDescription
tokenaddress
amountint64
newTotalSupplyint64

HTSTokenBurned

Emitted after a successful burn.

event HTSTokenBurned(address indexed token, int64 amount, int64 newTotalSupply);

Parameters

NameTypeDescription
tokenaddress
amountint64
newTotalSupplyint64

Errors

HTSTokenNotAssociated

account is not associated with token (HTS 184).

error HTSTokenNotAssociated(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSTokenAlreadyAssociated

account is already associated with token (HTS 194).

error HTSTokenAlreadyAssociated(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSInsufficientBalance

account holds too little of token (HTS 178 / 28).

error HTSInsufficientBalance(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSNonZeroBalance

account still holds a balance of token, so it cannot be dissociated (HTS 195).

error HTSNonZeroBalance(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSAccountIsTreasury

account is token's treasury, so it can never be dissociated from it (HTS 196).

error HTSAccountIsTreasury(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

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

NameTypeDescription
tokenaddress

HTSTokenNoSupplyKey

token has no supply key (HTS 180).

error HTSTokenNoSupplyKey(address token);

Parameters

NameTypeDescription
tokenaddress

HTSMaxSupplyReached

The mint would exceed token's max supply (HTS 236).

error HTSMaxSupplyReached(address token);

Parameters

NameTypeDescription
tokenaddress

HTSTokenPaused

token is paused (HTS 265).

error HTSTokenPaused(address token);

Parameters

NameTypeDescription
tokenaddress

HTSAccountFrozen

account is frozen for token (HTS 165).

error HTSAccountFrozen(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSKycNotGranted

account has no KYC grant for token (HTS 176).

error HTSKycNotGranted(address token, address account);

Parameters

NameTypeDescription
tokenaddress
accountaddress

HTSAllowanceExceeded

The diamond's allowance from owner on token is missing or too small (HTS 292 / 293).

error HTSAllowanceExceeded(address token, address owner);

Parameters

NameTypeDescription
tokenaddress
owneraddress

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

NameTypeDescription
tokenaddress

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

NameTypeDescription
selectorbytes4
responseCodeint64