| Crates.io | xforth |
| lib.rs | xforth |
| version | 0.1.0 |
| created_at | 2025-11-14 12:50:50.087656+00 |
| updated_at | 2025-11-14 12:50:50.087656+00 |
| description | CLI tool for bootstrapping x402 Solana projects. |
| homepage | https://github.com/cryptopatrick/xforth |
| repository | https://github.com/cryptopatrick/xforth |
| max_upload_size | |
| id | 1932772 |
| size | 281,461 |
Author's bio: Hi, I'm CryptoPatrick! I'm currently enrolled as an
Undergraduate student in Mathematics, at Chalmers & the University of Gothenburg, Sweden.
If you have any questions or need more info, then please join my Discord Channel: AiMath
What is xforth • Features • How To Use • Documentation • License
xforth is a Rust-based CLI tool that automates the complete setup process for x402 projects on the Solana blockchain. Through intelligent automation of keypair generation, wallet funding, token minting, and payment flow validation - the whole process is much smoother.
The tool provides three core commands that handle the complete setup lifecycle:
.env file with all necessary keys and program IDsxforth requires:
Install directly from crates.io:
cargo install xforth
Or build from source:
git clone https://github.com/cryptopatrick/xforth.git
cd xforth
cargo build --release
Bootstrap a complete x402 project in three commands:
# 1. Initialize your project (creates keypairs, config, and project structure)
xforth init my-payment-agent
# 2. Fund the wallets with SOL and mint test tokens
xforth fund
# 3. Validate the setup with a test payment transaction
xforth test
That's it! Your x402 project is now fully configured and ready for development.
Initialize a new x402 project:
xforth init [PROJECT_NAME]
Options:
PROJECT_NAME: Optional project name (default: "my-x402-agent")--rpc <URL>: Override default Devnet RPC endpoint--local: Use local Solana validator (http://127.0.0.1:8899)--json: Output results in JSON format--no-color: Disable colored outputWhat it does:
.env file with configurationExample output:
[ACTION] Initializing project: my-payment-agent
[LOG] Generated Agent/Payer keypair: 5Xr7...Abc
[LOG] Generated Facilitator/Receiver keypair: 9Yt3...Def
[LOG] Created project directory
[LOG] Generated .env configuration
[SUCCESS] Project initialized successfully!
Fund wallets and mint test tokens:
xforth fund
Options:
--rpc <URL>: Override default Devnet RPC endpoint--local: Use local Solana validator--json: Output results in JSON format--no-color: Disable colored outputWhat it does:
Example output:
[ACTION] Funding wallets...
[LOG] Airdropping 0.5 SOL to Agent: 5Xr7...Abc
[LOG] Retry 1/5 due to rate limit...
[LOG] Airdrop successful! Balance: 0.5 SOL
[LOG] Minting test tokens...
[SUCCESS] All wallets funded successfully!
Validate setup with test transaction:
xforth test
Options:
--rpc <URL>: Override default Devnet RPC endpoint--local: Use local Solana validator--json: Output results in JSON format--no-color: Disable colored outputWhat it does:
Example output:
[ACTION] Running test payment...
[LOG] Agent balance: 0.5 SOL
[LOG] Facilitator balance: 0.5 SOL
[LOG] Executing payment transaction...
[TX] 3Kp9...Xyz
[SUCCESS] Test payment completed successfully!
View transaction: https://explorer.solana.com/tx/3Kp9...Xyz?cluster=devnet
xforth init my-project --rpc https://my-custom-rpc.com
xforth fund --rpc https://my-custom-rpc.com
xforth test --rpc https://my-custom-rpc.com
# Start local Solana validator in another terminal
solana-test-validator
# Use xforth with local validator
xforth init my-project --local
xforth fund --local
xforth test --local
# Use JSON output for parsing in scripts
xforth init my-project --json --no-color > init-result.json
xforth fund --json --no-color > fund-result.json
xforth test --json --no-color > test-result.json
After running xforth init my-project, you'll have:
my-payment-agent/
├── Cargo.toml # Rust project configuration
├── .env # Environment variables (keypairs, program IDs)
└── src/
└── main.rs # Template for your x402 agent
The .env file contains:
AGENT_KEYPAIR=<base58-encoded-keypair>
FACILITATOR_KEYPAIR=<base58-encoded-keypair>
PROGRAM_ID=<deployed-program-address>
RPC_URL=https://api.devnet.solana.com
Security Note: Never commit your .env file to version control. Add it to .gitignore immediately.
Comprehensive documentation is available at docs.rs/xforth, including:
Keybase Verification: https://keybase.io/cryptopatrick/sigs/8epNh5h2FtIX1UNNmf8YQ-k33M8J-Md4LnAN
I'm just a lone dev, silently hacking away, in a place far far away. Please don't hesitate to tweet at me https://x.com/cryptopatrick/ if you found this project helpful in any way. You can also support me with Solana: 8uCGFmXRQPJQ8r16d9a1DroRcmmtzus3SFfTkteSt2Xj or Ethereum: 0x52a361c89ebF05C8ea3fA72fc43aDF30f53e2D21
Cheers!
Found a bug? Missing a specific feature? Contributions are welcome! Please see our contributing guidelines for details on:
This project is licensed under MIT. See LICENSE for details.