This project implements a Pump.fun-like bonding curve mechanism on the Solana blockchain using the Anchor framework. It enables token creation, trading via a bonding curve, and efficient state management for a decentralized token economy.
Ensure the following tools are installed on your system with the specified versions:
- Solana CLI: 2.1.22 (src:3861dceb; feat:1416569292, client:Agave)
- Anchor CLI: 0.31.1
- Rust: 1.86.0 (05f9846f8 2025-03-31)
- Node.js: v23.11.0
- Yarn: Latest version
Follow these steps to install the required tools:
Install the Solana CLI with the specified version:
curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bashVerify the version:
solana --versionExpected output: solana-cli 2.1.22 (src:3861dceb; feat:1416569292, client:Agave).
Install Anchor CLI version 0.31.1 via Cargo:
cargo install --git https://github.com/coral-xyz/anchor --tag v0.31.1 anchor-cli --lockedVerify the version:
anchor --versionExpected output: anchor-cli 0.31.1.
Install Rust if not already present:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shVerify the version:
rustc --versionExpected output: rustc 1.86.0 (05f9846f8 2025-03-31).
Install Node.js version 23.11.0 from nodejs.org, then install Yarn globally:
npm install -g yarnVerify the versions:
node --version
yarn --versionExpected outputs: v23.11.0 for Node.js and the latest Yarn version.
Clone the repository and install dependencies:
git clone https://github.com/yourusername/bonding_curve.git
cd bonding_curve
yarnThis installs all TypeScript dependencies listed in package.json.
Set the Solana CLI to use a local cluster for development:
solana config set --url http://localhost:8899If you need a new wallet for testing:
solana-keygen newSave the generated keypair for use in testing.
Compile the smart contract with Anchor:
anchor buildThis generates the compiled program in target/deploy/ (e.g., bonding_curve.so) and the IDL file for client interactions.
Run the test suite to validate the contract:
anchor testThis command:
- Launches a local Solana validator.
- Deploys the contract.
- Executes TypeScript tests in the
tests/directory.
Successful tests will display:
bonding_curve
✔ Initializes bonding curve (500ms)
✔ Creates token (600ms)
✔ Executes buy transaction (800ms)
3 passing (2s)
If tests fail, see Troubleshooting.
-
Build Fails:
- Ensure Rust and Anchor versions match the prerequisites.
- Run
cargo updateif dependencies are outdated.
-
Tests Fail:
- Confirm the local validator is running (
solana-test-validator). - Check wallet balance with
solana balance.
- Confirm the local validator is running (
-
Version Mismatch:
- Reinstall tools with the exact versions specified if compatibility issues arise.