Skip to content

feat(meta-hook): add Transfer Hook Solidity interfaces and KYCHook example#20

Open
skansal-rome wants to merge 2 commits into
masterfrom
feat-rome-meta-hook
Open

feat(meta-hook): add Transfer Hook Solidity interfaces and KYCHook example#20
skansal-rome wants to merge 2 commits into
masterfrom
feat-rome-meta-hook

Conversation

@skansal-rome
Copy link
Copy Markdown
Contributor

Summary

  • Adds ITransferHook interface for Solidity transfer hook contracts executed via Rome Meta-Hook Router
  • Adds TransferHookBase abstract contract with onlyRouter modifier and helper methods
  • Adds KYCHook example compliance hook with address allowlist for KYC enforcement
  • Uses bytes32 for Solana pubkeys, uint64 for token amounts (matching SPL conventions)

SPEC: specs/SPEC-rome-meta-hook.md (Rome Meta-Hook Router)
Part of: Multi-repo feature — Token-2022 Transfer Hook multiplexer with EVM bridge

Related PRs

  • rome-protocol/rome-meta-hook (new repo — Anchor program)
  • rome-protocol/rome-evm-private — DoEvmCallback instruction
  • rome-protocol/rome-sdk — MetaHookClient SDK crate
  • rome-protocol/tests — Integration test framework

Test plan

  • 16/16 Hardhat tests pass (npx hardhat test)
  • npx hardhat compile succeeds (32 contracts)
  • Integration tests with Rome EVM (deferred — tests repo)

🤖 Generated with Claude Code

Sattvik Kansal and others added 2 commits April 7, 2026 16:56
…acts [RED]

Add Solidity contracts and Hardhat tests for the Transfer Hook interface:

Contracts:
- ITransferHook.sol — Interface for EVM hook contracts (onTransfer)
- TransferHookBase.sol — Abstract base with onlyRouter modifier
- examples/KYCHook.sol — Example KYC compliance hook with allowlist

Tests (16 total):
- Deployment: router address, owner, zero-address rejection
- Address management: approve, revoke, non-owner rejection
- onTransfer approved: succeeds for KYC'd source + destination
- onTransfer non-approved: reverts TransferBlocked for source/dest/both
- onlyRouter modifier: rejects non-router, allows router
- Edge cases: zero amount, max uint64, approve-then-revoke

All 16 tests pass — contracts have real logic as leaf implementations.
The RED phase applies to the integration path where DoEvmCallback
and the Router program would invoke these contracts on-chain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deploy script derives the router EVM address from the Meta-Hook Router
program ID using keccak256(program_id ++ "callback_authority")[12..],
deploys KYCHook with the derived router address, and saves deployment
metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@skansal-rome skansal-rome force-pushed the feat-rome-meta-hook branch from a632875 to f26583c Compare April 8, 2026 00:01
@skansal-rome
Copy link
Copy Markdown
Contributor Author

KYCHook Deploy Script Added

Added scripts/deploy_kyc_hook.ts for deploying the KYCHook contract:

  • Derives router EVM address from Meta-Hook Router program ID using keccak256(program_id ++ "callback_authority")[12..]
  • Supports ROUTER_ADDRESS env var for direct override or META_HOOK_PROGRAM_ID for derivation
  • Includes inline base58 decoder (no external dependency)
  • Saves deployment metadata to deployments/{network}.json
  • Rebased onto latest master (18 commits including setup-local, gitignore, local stack docs)

Usage:

META_HOOK_PROGRAM_ID=MetaHk1111111111111111111111111111111111111 \
  npx hardhat run scripts/deploy_kyc_hook.ts --network local

🤖 This response was generated by Claude Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant