API Reference

sealed_token.leo #

This program implements compliant token transfers with freeze list functionality and role-based administration.

Constants #

Constant Type Description
TOKEN_ID field Identifier for the sealed token (1688926949047677303695061932791346field)
ZERO_ADDRESS address The zero address (aleo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3ljyzc)
PROGRAM_ADDRESS address Address of the program (aleo1t6aat4vk4u7jq2zk5fjk2actdp64s7n6m4pmn3xnw4quxw2545qsmk2mlc)
AUTHORIZED_UNTIL u32 Maximum authorization time (4294967295u32)
ADMIN_ROLE u8 Identifier for admin role (1u8)
INVESTIGATOR_ROLE u8 Identifier for investigator role (2u8)

Data Structures #

MerkleProof #

struct MerkleProof {
    siblings: [field; 16],
    leaf_index: u32
}

Used to verify Merkle proofs for address verification.

ComplianceRecord #

record ComplianceRecord {
    owner: address,
    amount: u128,
    sender: address,
    recipient: address
}

A record that keeps track of transaction details for compliance purposes.

TokenOwner #

struct TokenOwner {
    account: address,
    token_id: field
}

Represents a token owner with their account and token identifier.

Mappings #

Mapping Type Description
freeze_list address => bool Maps addresses to freeze status
freeze_list_index u32 => address Maps indices to frozen addresses
freeze_list_root u8 => field Stores the Merkle root of the freeze list
roles u8 => address Maps role identifiers to addresses

Administrative Functions #

update_freeze_list #

transition update_freeze_list(account: address, is_freezed: bool, freezed_index: u32, new_root: field) -> Future

Updates the freeze status of an account. Can only be called by the admin.

Parameters:

  • account: The address to update
  • is_freezed: Whether the address should be frozen
  • freezed_index: The index in the freeze list
  • new_root: The new Merkle root after update

update_investigator_address #

transition update_investigator_address(new_investigator_address: address) -> Future

Updates the investigator address. Can only be called by the admin.

Parameters:

  • new_investigator_address: The new investigator address

update_admin_address #

transition update_admin_address(new_admin_address: address) -> Future

Updates the admin address. Can only be called by the current admin.

Parameters:

  • new_admin_address: The new admin address

Transfer Functions #

transfer_public #

transition transfer_public(public recipient: address, public amount: u128) -> Future

Transfers tokens from the caller’s public balance to a recipient’s public balance.

Parameters:

  • recipient: The address to receive tokens
  • amount: The amount of tokens to transfer

transfer_public_as_signer #

transition transfer_public_as_signer(public recipient: address, public amount: u128) -> Future

Transfers tokens from the signer’s public balance to a recipient’s public balance.

Parameters:

  • recipient: The address to receive tokens
  • amount: The amount of tokens to transfer

transfer_public_to_priv #

transition transfer_public_to_priv(
    recipient: address,
    public amount: u128,
    recipient_merkle_proofs: [MerkleProof;2],
    investigator_address: address
) -> (ComplianceRecord, token_registry.aleo/Token, Future)

Transfers tokens from the caller’s public balance to a recipient’s private balance.

Parameters:

  • recipient: The address to receive tokens
  • amount: The amount of tokens to transfer
  • recipient_merkle_proofs: Merkle proofs for the recipient address
  • investigator_address: The address of the investigator for compliance records

Returns:

  • ComplianceRecord: A record of the transaction for compliance
  • token_registry.aleo/Token: The token record
  • Future: The future of the transaction

transfer_private #

transition transfer_private(
    recipient: address,
    amount: u128,
    input_record: token_registry.aleo/Token,
    sender_merkle_proofs: [MerkleProof;2],
    recipient_merkle_proofs: [MerkleProof;2],
    investigator_address: address
) -> (ComplianceRecord, token_registry.aleo/Token, token_registry.aleo/Token, Future)

Transfers tokens from the caller’s private balance to a recipient’s private balance.

Parameters:

  • recipient: The address to receive tokens
  • amount: The amount of tokens to transfer
  • input_record: The token record to transfer from
  • sender_merkle_proofs: Merkle proofs for the sender address
  • recipient_merkle_proofs: Merkle proofs for the recipient address
  • investigator_address: The address of the investigator for compliance records

Returns:

  • ComplianceRecord: A record of the transaction for compliance
  • Two token_registry.aleo/Token records
  • Future: The future of the transaction

transfer_priv_to_public #

transition transfer_priv_to_public(
    public recipient: address,
    public amount: u128,
    input_record: token_registry.aleo/Token,
    sender_merkle_proofs: [MerkleProof; 2],
    investigator_address: address
) -> (ComplianceRecord, token_registry.aleo/Token, Future)

Transfers tokens from the caller’s private balance to a recipient’s public balance.

Parameters:

  • recipient: The address to receive tokens
  • amount: The amount of tokens to transfer
  • input_record: The token record to transfer from
  • sender_merkle_proofs: Merkle proofs for the sender address
  • investigator_address: The address of the investigator for compliance records

Returns:

  • ComplianceRecord: A record of the transaction for compliance
  • token_registry.aleo/Token: The token record
  • Future: The future of the transaction

merkle_tree.leo #

A utility program that provides Merkle tree operations for address verification.

Data Structures #

MerkleProof #

struct MerkleProof {
    siblings: [field; 16],
    leaf_index: u32
}

Used to verify Merkle proofs for address verification.

Tree Building Functions #

build_tree #

transition build_tree(leaves: [address; 8]) -> [field; 15]

Builds a Merkle tree with 8 leaves.

Parameters:

  • leaves: An array of 8 addresses to use as leaves

Returns:

  • An array of field elements representing the entire tree

build_tree16 #

transition build_tree16(leaves: [address; 16]) -> [field; 31]

Builds a Merkle tree with 16 leaves.

Parameters:

  • leaves: An array of 16 addresses to use as leaves

Returns:

  • An array of field elements representing the entire tree

Verification Functions #

verify_non_inclusion #

transition verify_non_inclusion(addr: address, merkle_proofs: [MerkleProof;2]) -> field

Verifies that an address is not included in a Merkle tree.

Parameters:

  • addr: The address to check
  • merkle_proofs: Two Merkle proofs for verification

Returns:

  • The Merkle root if verification is successful

Helper Functions #

  • calculate_hash_for_neighbor: Calculates a hash for a neighbor in the Merkle tree
  • calculate_root_siblings: Calculates the root from siblings path
  • calculate_tree_depth: Calculates the depth of a Merkle tree