Skip to content

Implement balance and transfer functions #3

Description

@Nemenwa

Description:
Implement the core token transfer functions: balance, transfer, and transfer_from.
Function signatures:
rustpub fn balance(env: Env, id: Address) -> i128

pub fn transfer(
env: Env,
from: Address,
to: Address,
amount: i128,
) -> Result<(), ContractError>

pub fn transfer_from(
env: Env,
spender: Address,
from: Address,
to: Address,
amount: i128,
) -> Result<(), ContractError>
Requirements:

transfer must call from.require_auth()
transfer_from must call spender.require_auth() and check allowance
Both transfer functions must call the compliance contract's check_transfer_allowed(from, to) before executing. If compliance check fails, return ContractError::TransferNotAllowed.
Transfer amount must be > 0. If not, return ContractError::InvalidAmount.
Sender must have sufficient balance. If not, return ContractError::InsufficientBalance.
On successful transfer, emit a Transfer event.

Acceptance criteria:

All three functions implemented
Compliance check integration tested (mock the compliance contract)
All error cases covered
Events emitted correctly

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions