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.
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/hts-system-contract/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/hts-system-contract/
1Skills CLI (Vercel)
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a codex2Manually: put the files in place
.agents/skills/hts-system-contract/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a cursor2Manually: put the files in place
.cursor/skills/hts-system-contract/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install hedera-dev/hedera-skills hts-system-contract2Manually: put the files in place
.github/skills/hts-system-contract/SKILL.md1Skills CLI (Vercel)
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a gemini-cli2Platform CLI
gemini skills install https://github.com/hedera-dev/hedera-skills --path plugins/system-contracts/skills/hts-system-contractManually: put the files in place
.devin/skills/hts-system-contract/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add hedera-dev/hedera-skills --skill hts-system-contract -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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