Skip to content
Lattice

HTSAdapter

Git Source

Inherits: IHTSAdapter

Title: HTSAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)

Diamond facet that makes the diamond a first-class Hedera Token Service account: association, treasury transfers, and creation / mint / burn of tokens keyed to the diamond.

Stateless delegator — all logic and storage live in HTSAdapterLib. Consumers inherit this contract and add AccessControl + an initializer. Only meaningful on Hedera (chain ids 295 / 296 / 297 / 298).

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Hedera

Functions

isAssociated

True if the diamond is associated with token (HIP-719 facade isAssociated()).

function isAssociated(address token) external view virtual override 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 virtual override returns (bool isToken);

Parameters

NameTypeDescription
tokenaddress

Returns

NameTypeDescription
isTokenbool

htsTokenType

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

function htsTokenType(address token) external view virtual override 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 virtual override 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 virtual override;

Parameters

NameTypeDescription
tokenaddress

dissociateToken

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

function dissociateToken(address token) external virtual override;

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 virtual override 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
        virtual
        override
        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 virtual override;

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 virtual override;

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 virtual override;

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
        virtual
        override
        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
        virtual
        override
        returns (int64 newTotalSupply);

Parameters

NameTypeDescription
tokenaddress
amountint64
serialNumbersint64[]

Returns

NameTypeDescription
newTotalSupplyint64

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect HTSAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: associateToken(address) 0xa7efe348 burnToken(address,int64,int64[]) 0xd6910d06 createFungibleToken(string,string,string,int32,int64,int64) 0xdeaac2bb createNonFungibleToken(string,string,string,int64) 0x6830760a createdTokens() 0x54771086 dissociateToken(address) 0xd5d607b6 htsTokenType(address) 0xcaaf0325 isAssociated(address) 0xd55fe582 isHTSToken(address) 0x20cab858 mintToken(address,int64,bytes[]) 0xe0f4059a transferNFT(address,address,int64) 0x84ec4652 transferToken(address,address,int64) 0x75fd1606 transferTokenFrom(address,address,address,int64) 0x5f34cf96

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes