src-token
v1.0.1
Published
This project implements a custom SPL Token using **Token-2022** with advanced features like **transfer hooks** for transfer restrictions, taxes, burns, and more. It includes multiple Solana programs written using the **Anchor framework**.
Readme
📘 SRC Token on Solana (Token-2022 + Transfer Hook)
This project implements a custom SPL Token using Token-2022 with advanced features like transfer hooks for transfer restrictions, taxes, burns, and more. It includes multiple Solana programs written using the Anchor framework.
📦 Prerequisites
🛠️ 1. Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
rustup install stable📁 2. Install Solana CLI
sh -c "$(curl -sSfL https://release.solana.com/v1.18.4/install)"Add Solana CLI to your PATH:
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
solana --version🔧 3. Install Anchor
cargo install --git https://github.com/coral-xyz/anchor anchor-cli --tag v0.29.0
anchor --version🧶 4. Install Node.js + Yarn
brew install node
npm install -g yarn📁 Project Structure
src_token/
│
├── programs/
│ ├── src_token/ # Main token logic (mint management, DAO, unlocks)
│ └── transfer_hook/ # Hook logic for transfer interception (e.g., tax)
│
├── sdk/ # TypeScript SDK for interacting with the program
├── idl/ # Anchor-generated IDLs
├── migrations/ # Anchor migrations
└── Anchor.toml # Anchor configuration🚀 Build & Deploy
⚙️ Set Cluster
solana config set --url https://api.devnet.solana.comOr for localnet:
solana-test-validator
solana config set --url http://127.0.0.1:8899🔐 Setup Wallet
Note : airdrop is only for non-mainnet
solana-keygen new --outfile ~/.config/solana/id.json
solana airdrop 2🔨 Build Contracts
anchor buildThis compiles all programs and generates their keypairs in target/deploy/ and IDLs in target/idl/.
📬 Get Program Addresses
After build, extract your program addresses:
solana address -k target/deploy/src_token-keypair.json
solana address -k target/deploy/transfer_hook-keypair.jsonThen update declare_id! in each program’s lib.rs:
programs/src_token/src/lib.rs
declare_id!("YourGeneratedSrcTokenProgramID");programs/transfer_hook/src/lib.rs
declare_id!("YourGeneratedTransferHookProgramID");This step is required before you run anchor deploy.
🔧 Update Anchor.toml Before Deploying
Before deploying, update your Anchor.toml with cluster (mainnet, devnet, localnet, testnet) and programs addresses:
[programs.devnet]
src_token = "YourGeneratedSrcTokenProgramID"
transfer_hook = "YourGeneratedTransferHookProgramID"
[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"📤 Deploy Programs
anchor deploy -p transfer_hook
anchor deploy -p src_token💸 Deployment Cost Estimate
| Operation | Estimated Cost (SOL) | |----------------------------------|--------------------------| | DAO program | ~2.2749 | | Transfer hook program | ~1.4000 | | Mint Account (Token-2022) | ~0.0025 | | Associated Token Accounts (x3) | ~0.0075 | | TransferHook Init + Mint | ~0.0015 – 0.0020 | | UnlockManager Account | ~0.0020 | | Total | ~3.6839 – 3.6844 SOL |
⚙️ Config Example
Update scripts/config.ts
💡 Run initialization (creates token + initializes DAO, Unlock Plans and other configurations)
pnpm initialize💡 Create Meteora one-sided liquidity pool
Follow the set-up quide
https://docs.meteora.ag/token-launch-pools/steps-to-create-a-pool-for-a-token-launch/create-dlmm-launch-pool
- It supports 2022 spl token standart.
- Base token - should be SRCoin.
- Quote token can be SOL or USDC only.
- After successful pool creation, owner can add as much liquidity as he wants.
Note: also two-sided pool can be created https://app.meteora.ag/pools/create
🧪 Testing
Rust Tests
anchor test📦 Publishing SDK (optional)
cd sdk
pnpm publish --access public --no-git-checks🧼 Troubleshooting
If the program deployment was interrupted (e.g., due to a dropped connection or CLI crash), your SOL may be locked in a program buffer account. To recover it:
- Run the following command to locate the buffer account:
solana program show --programs - Look for an entry with a program address and a corresponding buffer account.
- If the program was not finalized (i.e., program not deployed or buffer not closed), you can recover the SOL using:
Replace <BUFFER_ADDRESS> with the actual buffer address shown.solana program close <BUFFER_ADDRESS> - This will return the unused SOL back to your wallet. After that try again. With this approach you can close any of your existing programs.
