This project is a basic token tracking application on the Solana blockchain. It includes a smart contract (program) written in Rust using the Anchor framework and a command-line interface (CLI) for user interaction.
Right now deployed in devnet, feel free to roam around
- Deposit: Users can deposit any SPL token into the program.
- Withdraw: Users can withdraw tokens back to their wallet.
- Balance Tracking: The program maintains an on-chain account for each user to track their balance.
- Events: Emits
DepositEventandWithdrawEventfor easy transaction history tracking.
-
Clone the repository:
-
Build and deploy the Solana program to devnet:
anchor build anchor deploy
Note: Anchor will automatically update the program ID in
lib.rsandAnchor.toml. -
Create a new SPL token and fund your account:
spl-token create-token spl-token create-account <MINT_ADDRESS> spl-token mint <MINT_ADDRESS> <AMOUNT> <YOUR_ACCOUNT_ADDRESS>
The CLI tool is located in the cli-tool directory.
P.S. You probably want to recompile cli tool with your own token.
Or you can ask me to mint you some
-
Build the CLI:
cd cli-tool cargo build --release -
Interact with the program:
-
Check balance:
./target/release/cli-tool balance --keypair <path-to-your-keypair.json>
-
Deposit tokens:
./target/release/cli-tool deposit --amount <amount> --keypair <path-to-your-keypair.json>
-
Withdraw tokens:
./target/release/cli-tool withdraw <amount> --keypair <path-to-your-keypair.json>
-
programs/token_tracker/src/lib.rs: The Solana smart contract logic.cli-tool/src/main.rs: The command-line interface tool.Anchor.toml: Anchor configuration file.