# Hts Evm Hybrid

> Call Hedera Token Service from Solidity via HTS system contract at 0x167 — associate, mint, transfer HTS tokens inside contracts, differences vs ERC-20 facade on HTS tokens, reentrancy considerations for precompile calls, 2023 HTS allowance exploit lessons. Use when user mentions HTS precompile, IHederaTokenService, associateToken Solidity, HTS from contract, reentrancy Hedera precompile, Uniswap-style hooks on Hedera.

- Skill: `evaluris-solutions/hts-evm-hybrid` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add evaluris-solutions/hts-evm-hybrid`
- Raw SKILL.md: https://api.skillmd.com/api/skills/evaluris-solutions/hts-evm-hybrid/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: Evaluris-Solutions (https://skillmd.com/u/evaluris-solutions)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/evaluris-solutions/hts-evm-hybrid

---


## Overview

HTS exposes a **system contract** at address `0x0000000000000000000000000000000000000167` implementing `IHederaTokenService` functions callable from user contracts ([HTS system contract](https://docs.hedera.com/hedera/core-concepts/smart-contracts/tokens-managed-by-smart-contracts/hedera-token-service-system-contract.md)).

## When to use this skill

- Orchestrating HTS mint/associate/transfer inside contract logic.
- Auditing **hook/reentrancy** interactions introduced by HIP-1195-style allowance behaviors.

## Prerequisites

- Working Hardhat → Hashio setup (`hedera-smart-contract-evm`).
- Correct conversion between **token ID** / **account ID** and **EVM address** representations — validate utilities before production.

## Workflow

1. Import official interface ABI from Hashgraph samples or vendor packages — demo uses [contracts/IHederaTokenServiceMinimal.sol](contracts/IHederaTokenServiceMinimal.sol).

2. Route calls through address `HederaPrecompileAddresses.HTS`.

3. Decode **response codes** — success vs failure enums differ from raw `require` checks; production code must branch on returned `int64`.

4. **Reentrancy** — external calls to HTS may invoke token hooks; treat like external calls in Checks-Effects-Interactions ordering.

5. **Security history** — read [references/precompile-vuln-taxonomy.md](references/precompile-vuln-taxonomy.md) for classes of failures including the **2023 HTS allowance incident**.

Deploy demo: [scripts/precompile-deploy.cjs](scripts/precompile-deploy.cjs).

## Examples

**Example 1**

> “Associate my contract’s callers with token X.”

Usually wrong pattern — association targets **accounts**, not transient callers; prefer explicit associate flows.

**Example 2**

> “Mint inside contract after deposit.”

Ensure `supplyKey` authorizations align with contract-controlled keys or delegated signatures.

**Example 3**

> “Why did ERC-20 transfer behave differently than HTS?”

ERC-20 facade paths still obey HTS association/KYC rules under the hood.

## Troubleshooting

| Issue | Tip |
| --- | --- |
| `INVALID_TOKEN_ID` | Address conversion incorrect |
| Unexpected hook recursion | Audit HIP-1195 interactions |

## References

- Local: [references/precompile-addresses.md](references/precompile-addresses.md), [references/precompile-vuln-taxonomy.md](references/precompile-vuln-taxonomy.md), [references/solidity-htst-examples.md](references/solidity-htst-examples.md)

