Quickstart
Go from two funded testnet accounts to a settled recurring pull in about five minutes.
This guide runs a full billing cycle against the deployed Orbit contract on Stellar Testnet using only the Stellar CLI.
Prerequisites
- Stellar CLI installed
- A terminal with
bash
Set up
Export the network constants
export ORBIT=CAZBZBUWBSQYK2RZ6WHMXVDLIQHSU5WD7ANZYL6HLNSCRUOTNYCDYQNG
# Testnet native-asset SAC. Use it as a stand-in for USDC so no trustline is needed.
export TOKEN=$(stellar contract id asset --asset native --network testnet)Create and fund three identities
stellar keys generate merchant --network testnet --fund
stellar keys generate subscriber --network testnet --fund
stellar keys generate contractor --network testnet --fund
export MERCHANT=$(stellar keys address merchant)
export SUBSCRIBER=$(stellar keys address subscriber)
export CONTRACTOR=$(stellar keys address contractor)Run a billing cycle
Subscriber approves Orbit on the token
The allowance caps the total Orbit can ever move for this subscriber. This one covers 12 cycles of 29 units.
stellar contract invoke --id $TOKEN --source subscriber --network testnet -- \
approve \
--from $SUBSCRIBER \
--spender $ORBIT \
--amount 3480000000 \
--live_until_ledger 5000000live_until_ledger must be in the future and within the network's maximum entry TTL. After that ledger the allowance expires and every pull fails.
Subscriber creates the vault
29 units every 30 days (2592000 seconds). No tokens move at this step.
stellar contract invoke --id $ORBIT --source subscriber --network testnet -- \
create_vault \
--user $SUBSCRIBER \
--merchant $MERCHANT \
--token $TOKEN \
--amount_per_interval 290000000 \
--interval_seconds 2592000Merchant pulls the first cycle
The first pull on a new vault is allowed immediately.
stellar contract invoke --id $ORBIT --source merchant --network testnet -- \
pull_funds --user $SUBSCRIBER --merchant $MERCHANTConfirm the cadence guard
Run the same pull again. It fails with Too early to pull funds because 30 days have not passed on the ledger.
stellar contract invoke --id $ORBIT --source merchant --network testnet -- \
pull_funds --user $SUBSCRIBER --merchant $MERCHANT
# Error: ... Too early to pull fundsPay a contractor
Merchant approves Orbit for the payroll total
stellar contract invoke --id $TOKEN --source merchant --network testnet -- \
approve --from $MERCHANT --spender $ORBIT --amount 100000000 --live_until_ledger 5000000Disburse
stellar contract invoke --id $ORBIT --source merchant --network testnet -- \
batch_disburse \
--sender $MERCHANT \
--token $TOKEN \
--splits '[{"recipient":"'$CONTRACTOR'","amount":"100000000"}]'You have opened a vault, settled a pull, seen the cadence guard reject a second pull, and run a payroll. Look up each transaction on stellar.expert.