This project implements an Escrow program using the Anchor framework for the Solana blockchain. The program allows users to create and accept token exchange offers in a secure manner.
- Rust
- Solana CLI
- Anchor CLI
- Node.js and npm
programs/escrow/src/lib.rs
: Main program file.programs/escrow/src/constants.rs
: File for storing constants.programs/escrow/src/state/mod.rs
: Module for connecting state definitions.programs/escrow/src/state/offer.rs
: State definition for the offer.programs/escrow/src/instructions/mod.rs
: Module for connecting instructions.programs/escrow/src/instructions/make_offer.rs
: Instruction for creating an offer.programs/escrow/src/instructions/take_offer.rs
: Instruction for accepting an offer.tests/escrow.ts
: Tests for the Escrow program.
-
Initialize a new Anchor project:
anchor init escrow --template=multiple
-
Navigate to the project directory:
cd escrow
-
Install dependencies:
npm install @solana/spl-token npm install @solana-developers/helpers
-
Build the project:
anchor build
Defines the structure and logic for creating a token exchange offer.
- File:
programs/escrow/src/instructions/make_offer.rs
- Function:
make_offer
Defines the structure and logic for accepting a token exchange offer.
- File:
programs/escrow/src/instructions/take_offer.rs
- Function:
take_offer
Run the tests to ensure the program works as expected:
anchor test