This Anchor-based Solana program enables a whitelist-gated token sale with a fixed token price and a purchase limit per wallet.
- Initialize Sale: Set token price, wallet purchase limit, and total supply.
- Whitelist Users: Add or remove users from the whitelist.
- Purchase Tokens: Allow whitelisted users to buy tokens.
- Set Token Price: Update the token price.
- Pause/Resume Sale: Temporarily halt or resume the sale.
- Return Tokens: Return tokens to the vault.
pub fn initialize(ctx: Context<Initialize>, token_price: u64, purchase_limit_per_wallet: u64, total_supply: u64) -> Result<()>;
pub fn whitelist_user(ctx: Context<WhitelistUser>, user: Pubkey) -> Result<()>;
pub fn purchase_tokens(ctx: Context<PurchaseTokens>, amount: u64) -> Result<()>;
pub fn remove_whitelist_user(ctx: Context<RemoveWhitelistUser>, user: Pubkey) -> Result<()>;
pub fn set_token_price(ctx: Context<SetTokenPrice>, new_price: u64) -> Result<()>;
pub fn pause_sale(ctx: Context<PauseSale>) -> Result<()>;
pub fn resume_sale(ctx: Context<ResumeSale>) -> Result<()>;
pub fn return_tokens(ctx: Context<ReturnTokens>, amount: u64) -> Result<()>;
State of the sale, including token mint, vault, and sale parameters.
State of a whitelisted buyer, including purchase amount and whitelist status.
- Rust: Ensure you have Rust installed. You can install it from here.
- Solana CLI: Install the Solana CLI tools by following the instructions here.
- Anchor: Install Anchor by following the instructions here.
- Node.js: Ensure you have Node.js and npm installed. You can download them from here.
- Clone the repository:
git clone https://github.com/whitelist_token.git cd whitelist_token
- Install dependencies:
npm install
- Build the project:
anchor build
- Deploy the program:
anchor deploy
- Verify the deployment: Ensure the program ID in lib.rs matches the deployed program ID.
-
Initialize: Set up your Solana environment by configuring your wallet and network settings.
-
Run the program: Execute the program using Solana CLI commands or scripts provided in the repository.
-
Test the program: Run the tests to ensure everything works correctly:
anchor test
Please open issues or submit pull requests for improvements or bug fixes.
-
Anchor: Framework for Solana programs.
-
Anchor-Spl-Token: SPL Token library for working with the Solana program tokens.
If you have any questions, feel free to reach out at [[email protected]].