This project implements a whitelist-gated token sale using Anchor, a framework for Solana programs. The program allows whitelisted users to purchase tokens at a static price with a limit per wallet address.
Develop a program using Native Rust or Anchor to allow users to participate in a whitelist-gated sale for a new token. Ensure the token price remains static and set a purchase limit per wallet.
- Whitelist-Gated Sale: Allows only whitelisted users to purchase tokens.
- Static Token Price: The token price remains static throughout the sale.
- Purchase Limit: Sets a purchase limit per wallet address.
- Rust
- Solana CLI
- Node.js
- Yarn
- Anchor
-
Install Solana CLI:
sh -c "$(curl -sSfL https://release.solana.com/stable/install)"
-
Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install Node.js and Yarn:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash nvm install --lts npm install --global yarn
-
Install Anchor:
cargo install --git https://github.com/project-serum/anchor --tag v0.19.0 anchor-cli --locked
-
Clone the repository:
[email protected]:0xCipherCoder/whitelist-token-sale.git cd whitelist-token-sale
-
Install dependencies:
npm install anchor build
-
Deploy the programs to Solana Local Tesnet:
anchor deploy
-
Build the Solana program:
anchor build
-
Deploy the program to your local Solana cluster:
anchor deploy
-
Ensure your local Solana test validator is running:
solana-test-validator
-
Run the tests:
anchor test
anchor test
Finished release [optimized] target(s) in 0.14s
Found a 'test' script in the Anchor.toml. Running it as a test suite!
Running test suite: "/home/pradip/Cipher/OpenSource/whitelist-token-sale/Anchor.toml"
whitelist-token-sale
✔ Initializes the sale correctly
✔ Allows a whitelisted buyer to purchase tokens (413ms)
✔ Prevents non-whitelisted buyers from purchasing tokens (1258ms)
✔ Prevents buyers from exceeding the max tokens per wallet
4 passing (5s)