Skip to main content
skill CX Codex

hts-system-contract — Claude Code skill: what it does, how to install

Guides Solidity smart contract development for Hedera Token Service using the 0x167 precompile. Helps create native tokens, set up access keys, and handle compliance controls.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a claude-code
Open on GitHub

What hts-system-contract does

This skill guides the agent in developing Solidity smart contracts that interact with the Hedera Token Service (HTS) precompile at 0x167. It includes patterns for importing @hashgraph/smart-contracts packages, using standard HederaTokenService.sol interfaces or reverting variants such as SafeHTS.sol and SafeViewHTS.sol.

It covers configuring seven distinct token key types via KeyHelper to manage admin operations, KYC, account freezing, wipes, supply changes, custom fee updates, and pauses. The instructions also enforce the Hedera association model, requiring accounts to call associateToken before receiving newly minted tokens.

Token deployment fails with INSUFFICIENT_TX_FEE if gas alone is provided. Supplying explicit native HBAR value using {value: msg.value} in the deployment call is mandatory.

What it helps with

  • write Solidity contracts for Hedera-native tokens via HTS
  • configure token permission keys with KeyHelper
  • implement NFT minting workflows on Hedera
  • handle Hedera response codes and compliance controls

Example prompts for the agent

  • Create a Solidity function to deploy an HTS token with msg.value
  • Add supply and pause keys using KeyHelper for a new NFT collection
  • Write an associateToken check with HederaResponseCodes verification

How to install hts-system-contract

1Skills CLI (Vercel)

npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a claude-code

2Manually: put the files in place

~/.claude/skills/hts-system-contract/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/hts-system-contract/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about hts-system-contract

How to install hts-system-contract in Claude Code?

Run npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a claude-code. The file will be placed in ~/.claude/skills/hts-system-contract/SKILL.md.

What does hts-system-contract do?

It provides patterns and rules for interacting with Hedera Token Service via the 0x167 precompile. It guides token creation, key permission setups, fee configurations, and response code validation.

Why does token creation fail with INSUFFICIENT_TX_FEE?

Creating an HTS token requires an explicit payment in HBAR in addition to gas fees. You must supply HBAR via {value: msg.value} in your Solidity function call.

Source text

SKILL.md · Apache-2.0
---
name: hts-system-contract
description: Hedera Token Service (HTS) smart contract development. Use when creating, managing, or interacting with Hedera-native tokens via Solidity contracts. Triggers include HTS tokens, Hedera token creation, HTS precompile, token minting/burning on Hedera, KYC/freeze/pause token controls, custom fee schedules, NFT collections on Hedera, or any token operations using the 0x167 precompile.
---

# Hedera Token Service (HTS) System Contract

HTS precompile at `0x167` enables Solidity contracts to create and manage Hedera-native tokens with built-in compliance controls (KYC, freeze, pause) and custom fees.

## Quick Reference

**Imports:**

```solidity
import {HederaTokenService} from "@hashgraph/smart-contracts/contracts/system-contracts/hedera-token-service/HederaTokenService.sol";
import {KeyHelper} from "@hashgraph/smart-contracts/contracts/system-contracts/hedera-token-service/KeyHelper.sol";
import {ExpiryHelper} from "@hashgraph/smart-contracts/contracts/system-contracts/hedera-token-service/ExpiryHelper.sol";
import {HederaResponseCodes} from "@hashgraph/smart-contracts/contracts/system-contracts/hedera-token-service/HederaResponseCodes.sol";
```

**Safe variants** (auto-revert on failure): `SafeHTS.sol`, `SafeViewHTS.sol`

## Critical: HBAR Payment Required

Token creation requires explicit HBAR value payment (not just gas):

```solidity
// ❌ WRONG - fails with INSUFFICIENT_TX_FEE
(int rc, address token) = createNonFungibleToken(token);

// ✅ CORRECT
(int rc, address token) = createNonFungibleToken{value: msg.value}(token);
```

Call from TypeScript:

```typescript
await contract.createToken(name, symbol, {
  gasLimit: 350_000,
  value: ethers.parseEther("15"), // ~$1-2 USD of HBAR
});
```

## Token Key System

Seven key types control token operations (bit positions for `keyType` field):

| Key    | Bit | Value | Controls                     |
| ------ | --- | ----- | ---------------------------- |
| ADMIN  | 0   | 1     | Update token, keys, deletion |
| KYC    | 1   | 2     | Grant/revoke KYC             |
| FREEZE | 2   | 4     | Freeze/unfreeze accounts     |
| WIPE   | 3   | 8     | Wipe balances                |
| SUPPLY | 4   | 16    | Mint/burn                    |
| FEE    | 5   | 32    | Update fees                  |
| PAUSE  | 6   | 64    | Pause all operations         |

Use `KeyHelper` for key construction:

```solidity
keys[0] = getSingleKey(KeyType.SUPPLY, KeyValueType.CONTRACT_ID, address(this));
```

See [references/keys.md](references/keys.md) for key value types and JSON tuple format.

## Association Model

Accounts must associate with tokens before receiving them:

```solidity
int rc = associateToken(accountAddress, tokenAddress);
require(
    rc == HederaResponseCodes.SUCCESS ||
    rc == HederaResponseCodes.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT,
    "Association failed"
);
```

## Common Patterns

### Fungible Token Creation

```solidity
function createToken() external payable {
    IHederaTokenService.HederaToken memory token;
    token.name = "My Token";
    token.symbol = "MTK";
    token.treasury = address(this);
    token.expiry = createAutoRenewExpiry(address(this), 7776000); // 90 days

    (int rc, address created) = createFungibleToken{value: msg.value}(
        token, 1000000, 18  // initialSupply, decimals
    );
    require(rc == HederaResponseCodes.SUCCESS, "Create failed");
}
```

### Mintable NFT Collection

```solidity
function createNFT() external payable {
    IHederaTokenService.HederaToken memory token;
    token.name = "My NFT";
    token.symbol = "MNFT";
    token.treasury = address(this);
    token.tokenSupplyType = true;  // FINITE
    token.maxSupply = 10000;

    IHederaTokenService.TokenKey[] memory keys = new IHederaTokenService.TokenKey[](1);
    keys[0] = getSingleKey(KeyType.SUPPLY, KeyValueType.CONTRACT_ID, address(this));
    token.tokenKeys = keys;
    token.expiry = createAutoRenewExpiry(address(this), 7776000);

    (int rc, address created) = createNonFungibleToken{value: msg.value}(token);
    require(rc == HederaResponseCodes.SUCCESS, "Create failed");
}

function mintNFT(bytes memory metadata) external {
    bytes[] memory metas = new bytes[](1);
    metas[0] = metadata;
    (int rc, , int64[] memory serials) = mintToken(tokenAddress, 0, metas);
    require(rc == HederaResponseCodes.SUCCESS, "Mint failed");
}
```

### KYC-Enabled Token

Treasury must self-grant KYC after creation:

```solidity
// After token creation with KYC key
int kycRc = grantTokenKyc(tokenAddress, address(this));
require(kycRc == HederaResponseCodes.SUCCESS, "Self-KYC failed");
```

## Response Code Handling

Always check response codes. SUCCESS = 22.

```solidity
require(responseCode == HederaResponseCodes.SUCCESS, "Operation failed");
```

Common codes: See [references/response-codes.md](references/response-codes.md)

## Additional References

- **API Reference**: [references/api.md](references/api.md) - All function signatures
- **Custom Fees**: [references/fees.md](references/fees.md) - Fixed, fractional, royalty fees
- **Compliance Controls**: [references/compliance.md](references/compliance.md) - KYC, freeze, pause details
- **Struct Definitions**: [references/structs.md](references/structs.md) - HederaToken, Expiry, etc.
- **Troubleshooting**: [references/troubleshooting.md](references/troubleshooting.md) - Common errors and fixes

© hedera-dev · Apache-2.0 · hedera-dev/hedera-skills

Similar skills

All skills for Backend and APIs →

From the same set24

Quality Gates This skill wires up automatic code checks: lint and typecheck after every edit, a local CI run before push, and a five-stage deploy checklist. CX Codex +1 536installs Hedera Policy Creation Guides developers in creating blocking validation rules for Hedera Agent Kit tools. Useful when setting transaction thresholds, recipient allowlists, or execution limits. CX Codex +1 480installs Hedera Agent Kit v4 Migration Walks a project from [email protected] to v4: swaps packages, rewrites imports and ports custom tools to BaseTool. CX Codex +1 484installs Hedera Hook Creation Guides the creation of non-blocking observability hooks for Hedera Agent Kit tools. Useful when writing audit trails, counting tool invocations, or enriching session context. CX Codex +1 479installs agent-kit-plugin This skill guides the creation of Hedera Agent Kit plugins and tools. Use it when adding token, account, consensus, smart contract, or custom Hedera functionality. CX Codex +1 463installs hss-system-contract Guides assistants in building scheduled transactions via the Hedera Schedule Service contract at 0x16b. Useful for Solidity developers automating calls or token creation. CX Codex +1 461installs create-harness-spec Turns a Hedera feature idea into a runnable hedera-harness recipe: PRD, spec file and validators. Useful when you need a spec you can actually run. CX Codex +1 465installs hiero-cli Equips coding agents to interact with the Hedera network via hcli. Useful for minting tokens, deploying contracts, sending HBAR, and handling x402 paywalls. CX Codex +1 460installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor