A demonstration to show importance of account checks in account data matching course.
A demonstration to show importance of account checks in account-data-matching. This project demonstrates secure account data matching using Anchor and Solana. It implements a vault system with token management and withdrawal functionality.
npx create-solana-dapp my-project --template account-data-matching
- Rust and Cargo
- Solana CLI tools
- Node.js and Yarn
- Anchor Framework
-
Clone the repository:
git clone https://github.com/solana-developers/solana-account-data-matching cd account-data-matching
-
Install dependencies:
yarn install
-
Build the project:
anchor build
-
Run tests:
anchor test
programs/account-data-matching/src/lib.rs
: Main program logic for the vault systemtests/account-data-matching.ts
: Comprehensive test suiteAnchor.toml
: Anchor configuration and deployment settingsCargo.toml
: Rust dependenciesmigrations/deploy.ts
: Deployment script
- Secure vault initialization
- Token account management
- Withdrawal functionality with proper authorization checks
-
Initialize the vault:
await program.methods.initializeVault() .accounts({ vault: vaultPDA, tokenAccount: tokenPDA, withdrawDestination: withdrawDestination, mint: mint, authority: wallet.publicKey, }) .rpc()
-
Perform a withdrawal (ensure proper authorization):
await program.methods.insecureWithdraw() .accounts({ vault: vaultPDA, tokenAccount: tokenPDA, withdrawDestination: withdrawDestination, authority: wallet.publicKey, }) .rpc()
We welcome contributions! Please see our Contributing Guidelines for more details.