Payment plans driven by off-chain integrators.
- Approve the payment plan contract as the spender for the total amount to be sent.
token.approve(address(paymentPlanContract), totalAmount)
- Create a payment plan by calling
createPaymentPlan(address target, address token, uint256 amountPerInterval, uint256 totalIntervals, uint256 intervalLength)
- target is the recipient of payments
- token is the token to be used for payments
- amountPerInterval is the total amount to be transfered per interval
- totalInverals is the total number of intervals for the payment plan
- intervalLength is the number of seconds that each interval will be
- When a payment plan is started, an event is emitted to notify off-chain integrators.
When a new interval begins for a payment plan, an event is emitted specifying the exact unix timestamp when a payment can be facilitated. For off-chain integrators, all that is needed to initiate a payment is the plan id. Payment initiations can be batched together, as well. When an interval is fulfilled, an event is fired so that offchain integrators know to stop tracking it.
- Revoke approval for the payment plan contract
token.approve(address(paymentPlanContract), 0)
- Retrieve the payment plan id
- Call
cancelPaymentPlan(uint256 id)
curl -L https://foundry.paradigm.xyz | bash
source ~/[.zshrc | .bashrc | .bash_profile | .zsh_profile]
foundryup
forge build
forge test