Contract Methods
Exhaustive reference of all 14 public methods implemented in the contract.
Exhaustive technical reference of all public methods exposed by the SplitPayContract implementation.
Initializes the contract config with a designated administrator address.
- Authorization:
admin.require_auth() - Errors:
Error::AlreadyInitialized (1)if previously called.
pub fn initialize(env: Env, admin: Address) -> Result<(), Error>Creates a new payment pool with an initial status of Active.
- Authorization:
owner.require_auth() - State Changes: Sets
Poolin storage, initializes empty member address list, emitspool_created. - Errors:
Error::NotInitialized (2),Error::PoolAlreadyExists (16).
pub fn create_pool(env: Env, pool_id: u64, owner: Address, asset: Address) -> Result<(), Error>Adds a member address and their allocation share in basis points (10,000 = 100%).
- Authorization: Pool owner (
pool.owner.require_auth()) - Validation:
share_bps > 0 && share_bps <= 10000; cumulative shares cannot exceed 10,000. - Errors:
Error::PoolNotFound (3),Error::MemberAlreadyExists (6),Error::InvalidShare (9),Error::InvalidTotalShares (10).
pub fn add_member(env: Env, pool_id: u64, address: Address, share_bps: u32) -> Result<(), Error>Removes an existing member from the pool.
- Authorization: Pool owner (
pool.owner.require_auth()) - Errors:
Error::PoolNotFound (3),Error::MemberNotFound (5).
pub fn remove_member(env: Env, pool_id: u64, address: Address) -> Result<(), Error>Toggles pool status between Active (1) and Inactive (2).
- Authorization: Pool owner (
pool.owner.require_auth()) - Errors:
Error::PoolNotFound (3).
pub fn set_pool_status(env: Env, pool_id: u64, status: PoolStatus) -> Result<(), Error>Retrieves details of a registered pool.
pub fn get_pool(env: Env, pool_id: u64) -> Result<Pool, Error>Retrieves a specific member record within a pool.
pub fn get_member(env: Env, pool_id: u64, address: Address) -> Result<Member, Error>Returns an ordered vector of all configured members in a pool.
pub fn get_pool_members(env: Env, pool_id: u64) -> Result<Vec<Member>, Error>Records an unsettled payment targeting a pool. Verifies that total shares equal exactly 10,000 BPS before accepting.
- Authorization:
payer.require_auth() - Validation:
amount > 0, pool must beActive, sum of shares must be10,000. - Errors:
Error::InvalidAmount (11),Error::PaymentAlreadyExists (13),Error::InvalidPoolStatus (8),Error::InvalidTotalShares (10).
pub fn create_payment(env: Env, payment_id: u64, pool_id: u64, payer: Address, amount: i128) -> Result<(), Error>Atomically pulls funds from payer via SEP-41 token transfer, calculates exact distributions with deterministic remainder handling, and disburses tokens to all members.
- Authorization:
payment.payer.require_auth() - State Changes: Sets
payment.status = PaymentStatus::Settled, persistsDistributionstructs, emitspayment_settled. - Errors:
Error::PaymentNotFound (4),Error::PaymentAlreadySettled (14),Error::InvalidPoolStatus (8),Error::InvalidTotalShares (10).
pub fn settle_payment(env: Env, payment_id: u64) -> Result<(), Error>Retrieves status and details of a payment.
pub fn get_payment(env: Env, payment_id: u64) -> Result<Payment, Error>Retrieves the immutable distribution record for a specific recipient in a settled payment.
pub fn get_distribution(env: Env, payment_id: u64, recipient: Address) -> Result<Distribution, Error>Returns all distributions for a settled payment.
pub fn get_distributions(env: Env, payment_id: u64) -> Result<Vec<Distribution>, Error>