Skip to content

Latest commit

 

History

History
155 lines (103 loc) · 4.07 KB

File metadata and controls

155 lines (103 loc) · 4.07 KB

PetChain Smart Contract API Reference

Overview

The PetChain smart contract suite manages pet registration, medical records, ownership, and related services on the Stellar (Soroban) network. This document covers all public functions in the main PetChainContract and the VetRegistryContract.


Table of Contents

  1. Contract Statistics
  2. Admin & Multisig Management
  3. Pet Management
  4. Owner Management
  5. Vet Management
  6. Medical Records
  7. Vaccinations
  8. Lab Results
  9. Medications
  10. Treatments
  11. Insurance
  12. Grooming
  13. Nutrition
  14. Behavior & Training
  15. Activity Tracking
  16. Breeding
  17. Access Control
  18. Emergency Contacts
  19. Lost Pet Alerts
  20. Tag Linking
  21. Consent Management
  22. Vet Availability
  23. Vet Reviews
  24. Pet Multisig Transfer
  25. Contract Upgrade
  26. Vet Registry Contract

1. Contract Statistics

get_total_pets

Returns the total number of pets ever registered.

  • Parameters: env: Env
  • Returns: u64

get_species_count

Returns the number of registered pets for a given species.

  • Parameters: env: Env, species: String
  • Returns: u64

get_active_pets_count

Returns the number of currently active (non-archived) pets.

  • Parameters: env: Env
  • Returns: u64

2. Admin & Multisig Management

init_admin

Initialize a single admin for the contract.

  • Auth: admin must sign
  • Parameters: env: Env, admin: Address
  • Panics: If admin already set

init_multisig

Initialize multi-signature admin control.

  • Auth: invoker must sign and must be in admins list
  • Parameters: env: Env, invoker: Address, admins: Vec<Address>, threshold: u32
  • Panics: If admin already set, threshold is 0 or > admins.len(), or invoker not in list

propose_action

Propose a multi-signature admin action.

  • Auth: proposer must be an admin
  • Parameters: env: Env, proposer: Address, action: ProposalAction, expires_in: u64
  • Returns: u64 — proposal ID

approve_proposal

Approve a pending multi-signature proposal.

  • Auth: admin must be an admin
  • Parameters: env: Env, admin: Address, proposal_id: u64
  • Panics: If proposal not found, already executed, or expired

execute_proposal

Execute a proposal once threshold approvals are met.

  • Parameters: env: Env, proposal_id: u64
  • Panics: If threshold not met, already executed, or expired

get_proposal

Initialize multi-signature admin control.

Auth: invoker must sign and must be in admins list

Parameters:

  • env: Env
  • invoker: Address
  • admins: Vec<Address>
  • threshold: u32

Panics: If admin already set, threshold is 0 or > admins.len(), or invoker not in list


propose_action

Propose a multi-signature admin action.

Auth: proposer must be an admin

Parameters:

Statistics

get_vet_stats

Returns the activity statistics for a given vet.

Parameters:

  • env: Env - Contract environment
  • vet_address: Address - The vet's address

Returns: VetStats - Stats struct with the following fields:

  • total_records: u64 - Total medical records added by this vet
  • total_vaccinations: u64 - Total vaccinations administered
  • total_treatments: u64 - Total treatments recorded
  • pets_treated: u64 - Number of unique pets treated

Returns a zeroed VetStats if the vet has no recorded activity.

Example:

let stats = client.get_vet_stats(&vet_address);

Future Enhancements

Returns: u64