Prerequisites
Before starting, make sure you have:- Node.js 18+ and npm
curlandjq- A local Solana keypair file for your agent
- Dependencies for signing:
Endpoints Used in This Guide
1. Create or Load an Agent Wallet
Create a local keypair (once), then print your wallet address.BAGS_WALLET:
2. Initialize Authentication Challenge
Request a challenge message and nonce:3. Sign the Challenge Message
Themessage returned by init is base58-encoded. Decode it to bytes, sign using your Ed25519 key, then base58-encode the signature.
4. Complete Signature Callback
Send the signature payload:- API key returned immediately
- MFA required (
mfaRequired: true) andauthCodereturned
5. Handle MFA Callback (If Required)
If callback returnsmfaRequired: true, call the same endpoint again with your MFA code:
6. Store Credentials Securely
Save returned credentials in a local file:How the Skill Works After Authentication
Onceapi_key is stored, the skill follows a consistent pattern:
- Read
~/.config/bags/credentials.json - Call a domain endpoint with
x-api-key - If a transaction is returned, sign with local keypair
- Submit through
POST /solana/send-transaction
Skill Modules and Their Endpoints
| Skill module | Purpose | Main endpoints |
|---|---|---|
| AUTH.md | Wallet-signature auth + MFA | /agent/v2/auth/init, /agent/v2/auth/callback |
| FEES.md | Discover and claim earnings | GET /token-launch/claimable-positions, POST /token-launch/claim-txs/v3 |
| TRADING.md | Quote and swap tokens | GET /trade/quote, POST /trade/swap |
| LAUNCH.md | Create token metadata and launch tx | POST /token-launch/create-token-info, POST /fee-share/config, POST /token-launch/create-launch-transaction |
| WALLETS.md | Local wallet ops and signing | Uses API tx endpoints plus local signer script |
| HEARTBEAT.md | Periodic health checks | Reuses claimable positions + optional claim/trade flows |
Security and Reliability Notes
- Nonces are single-use and expire quickly (re-run init if expired).
- Never expose secret key bytes in logs.
- Keep keypair and credentials files at
chmod 600. - API key is shown once on successful callback; store it immediately.
- For retries, regenerate a fresh nonce and signature rather than replaying old payloads.
Common Errors
Nonce not found or expired: run init again, sign the new message, retry callback.Invalid signature: ensure you sign decoded message bytes, not the plain base58 string.Invalid or expired auth code: rerun signature callback to get a freshauthCode.Too many requests: wait and retry (auth endpoints are rate-limited).
