Compliance program

The Anchor program Token-2022 calls on every transfer of the sukuk.

tsamara-compliance is deployed on devnet at EjYxuJE4QE8P37scBxgWRHGigZ8hP6j3ysnSQ95MWXXG. The source is in contracts/programs/tsamara-compliance. It is unaudited.

Instructions

InstructionWho may call itWhat it does
initialize_seriesThe mint's freeze authorityWrites the series config and the list of extra accounts the hook needs
register_investorThe compliance authorityWrites an investor record with a country code; refused if the country is restricted
transfer_hookToken-2022, during a transferChecks the recipient and the holding cap

Accounts

AccountSeedsHolds
SeriesConfigconfig, mintThe compliance authority, the holding cap, up to 16 restricted jurisdictions
InvestorRecordinvestor, mint, walletThe wallet and its two-letter country code
Extra account metasextra-account-metas, mintThe accounts Token-2022 must pass to the hook

What the hook checks

  1. It is running inside a token transfer. The source account's transferring flag must be set, so the hook cannot be called directly to fake a check.
  2. The recipient has an investor record for this mint. The record is a derived address, so a record for another wallet or another series does not pass.
  3. The recipient's country is not restricted.
  4. The recipient's balance after the transfer does not exceed the holding cap.

Errors

ErrorMeaning
Signer is not the mint's freeze authoritySomeone other than the compliance authority tried to initialize or register
Too many restricted jurisdictionsMore than 16
The series is not offered to residents of this jurisdictionRestricted country, at registration or on transfer
Transfer would exceed the per-investor holding capThe recipient would hold more than the cap
The hook may only run during a token transferThe hook was called outside a transfer

Known limits

  • The hook does not run on mint, so the cap is not enforced by the program on a primary subscription (issue 21).
  • There is no instruction to change a series' rules after it is initialized.
  • The compliance authority is the mint's permanent delegate. The program does not constrain how that key is used.

Build

Install the Solana CLI and Anchor, then:

cd contracts
anchor build
bun run build     # also refreshes the binary the tests load

On this page