-
Notifications
You must be signed in to change notification settings - Fork 93
Open
Labels
Description
Description:
Create the on-chain payment escrow contract. When a shipment is funded, tokens are locked in the contract. They are released to the carrier on confirmed delivery, or refunded to the shipper on cancellation. Uses the SEP-41 token interface (token::Client) for actual token transfers.
Create:
contracts/escrow/Cargo.tomlcontracts/escrow/src/lib.rs
Acceptance Criteria:
-
EscrowError:AlreadyFunded,NotFunded,Unauthorized,NotInitialized,InvalidState,AlreadyDisputed -
EscrowStatus:Unfunded,Funded,Released,Refunded,Disputed -
EscrowRecordstruct:shipment_id: u64,shipper: Address,carrier: Option<Address>,token: Address,amount: i128,status: EscrowStatus -
DataKey:Escrow(u64),Admin -
initialize(env, admin) -
fund_escrow(env, shipment_id, shipper, carrier, token, amount)—shipper.require_auth(), callstoken::Client.transfer_from(contract, shipper, contract, amount)(requires priorapprove), stores record -
release_payment(env, shipment_id, caller)— only admin or shipper; status must beFunded; callstoken::Client.transfer(contract, carrier, amount); sets statusReleased -
refund_payment(env, shipment_id, caller)— only admin; status must beFunded; refunds to shipper; sets statusRefunded -
raise_dispute(env, shipment_id, caller)— shipper or carrier, fromFundedonly -
resolve_dispute(env, shipment_id, admin, release: bool)— admin only fromDisputed; releases or refunds -
get_escrow(env, shipment_id) - TTL extended on all write operations
- 8 unit tests including full happy path using
StellarAssetClientfor test token setup
Reactions are currently unavailable