This repository contains a sample implementation of an escrow system on the Solana blockchain.
The general concept of escrow is illustrated in the following diagram:
Here's how this escrow concept is implemented on Solana:
This repository includes the escrow program, client SDKs, and CLI tools. Feel free to explore the code to understand the Solana-specific implementation details.
To build and deploy the escrow program:
$ cargo build-sbf
$ solana program deploy --program-id target/deploy/escrow_program-keypair.json target/deploy/escrow_program.so
To create an escrow account:
$ cargo run --bin escrow-cli -- --escrow-program-id $(solana address -k target/deploy/escrow_program-keypair.json) [SEND_MINT_TOKEN_ADDRESS] 1 [RECEIVE_MINT_TOKEN_ADDRESS]
This will output the created escrow account address.
To interact with an existing escrow account:
$ cargo run --bin escrow-cli -- --escrow-program-id $(solana address -k target/deploy/escrow_program-keypair.json) [ESCROW_ACCOUNT_ADDRESS]
For a detailed explanation of this implementation, check out the following resource:
This book provides in-depth information about the escrow implementation and can help answer any questions you might have.