A Solana program built with the Steel framework that allows users to lock tokens for a specific time period, with options for early release through multi-signature approval.
This escrow program enables a secure way to lock tokens for a specified time period with the following features:
- Time-based Release: Tokens are automatically releasable after a predefined lock period
- Multi-signature Early Release: Tokens can be released early if both the initializer and a third-party arbitrator approve
- Early Cancellation Window: The initializer can cancel the escrow within 24 hours of creation
- Secure Token Custody: Tokens are held in a program-controlled vault until conditions are met
The program maintains several accounts to manage the escrow process:
- EscrowAccount: Stores the core escrow details (initializer, recipient, amount, timelock)
- SignatureTracker: Tracks approval status for early release
- EscrowVault: Holds the tokens during the escrow period
- VaultAuthority: A PDA that controls the vault
Alice wants to lock tokens for Bob with a 30-day timelock
- Alice initializes the escrow, specifying:
- Bob as the recipient
- A trusted third party as the arbitrator
- The amount of tokens to lock
- A 30-day timelock period
- Alice transfers tokens to the escrow vault
- Alice can cancel the escrow and retrieve tokens within 24 hours if needed
- After 24 hours, Alice can only approve early release alongside the arbitrator
Alice needs to approve early release
- If circumstances require early release before 30 days
- Alice submits an approval transaction
- If the arbitrator also approves, Bob can claim tokens early
Bob wants to claim tokens after the timelock expires
- After 30 days, Bob submits a claim transaction
- The program verifies the timelock has expired
- Tokens are transferred to Bob's account automatically
Bob needs tokens before the timelock expires
- Bob requests approval from Alice and the arbitrator
- Once both approve, Bob can claim tokens early
- Without both approvals, Bob must wait for the timelock to expire
Charlie needs to approve early release
- Charlie reviews the situation requiring early release
- If appropriate, Charlie submits an approval transaction
- If Alice has also approved, this enables Bob to claim tokens early
- Alice creates an escrow for Bob with a 30-day timelock
- After 30 days, Bob claims the tokens
- The escrow completes successfully
- Alice creates an escrow for Bob with a 30-day timelock
- After 15 days, circumstances require early release
- Alice submits an approval
- The arbitrator (Charlie) submits an approval
- Bob claims tokens early
- The escrow completes successfully
- Alice creates an escrow for Bob with a 30-day timelock
- Within 24 hours, Alice decides to cancel
- Alice cancels the escrow
- Tokens return to Alice's account
Consts
– Program constants.Error
– Custom program errors.Event
– Custom program events.Instruction
– Declared instructions.
Add
– Add ...Initialize
– Initialize ...
Counter
– Counter ...
Compile your program:
steel build
Run unit and integration tests:
steel test