Skip to content

Implement token initialisation function #2

Description

@Nemenwa

Implement the initialize function which is called once on deployment to set up the contract state.
Function signature:
rustpub fn initialize(
env: Env,
admin: Address,
property_metadata: PropertyMetadata,
total_supply: i128,
compliance_contract: Address,
) -> Result<(), ContractError>
Requirements:

Can only be called once. Subsequent calls must return ContractError::AlreadyInitialized.
total_supply must be greater than 0. If not, return ContractError::InvalidSupply.
admin must be a valid Stellar address.
All PropertyMetadata fields must be non-empty strings.
On success, emit an Initialized event with the property ID and total supply.
Assign the full total_supply to the admin balance on initialisation.

Acceptance criteria:

Function implemented in lib.rs, logic in a submodule
Error cases tested
Happy path tested
Initialized event emitted and tested

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