HTSAdapter
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
| 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 virtual override 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 virtual override 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 virtual override 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 virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| token | address |
dissociateToken
Dissociates the diamond from token (its balance must be zero).
function dissociateToken(address token) external virtual override;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 virtual override 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
virtual
override
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 virtual override;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 virtual override;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 virtual override;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
virtual
override
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
virtual
override
returns (int64 newTotalSupply);Parameters
| Name | Type | Description |
|---|---|---|
| token | address | |
| amount | int64 | |
| serialNumbers | int64[] |
Returns
| Name | Type | Description |
|---|---|---|
| newTotalSupply | int64 |
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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |