repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | name: pump-solana-dev |
| #3 | description: "Solana development patterns used in the Pump SDK — Anchor IDL-based program interaction, SPL Token and Token-2022 management, transaction construction with instruction composition, RPC batching, and cross-program coordination." |
| #4 | metadata: |
| #5 | openclaw: |
| #6 | homepage: https://github.com/nirholas/pump-fun-sdk |
| #7 | requires: |
| #8 | env: |
| #9 | - SOLANA_RPC_URL |
| #10 | --- |
| #11 | |
| #12 | # Solana Development — Web3.js, Anchor, SPL Tokens & On-Chain Patterns |
| #13 | |
| #14 | Apply Solana development patterns used throughout the Pump SDK: Anchor IDL-based program interaction, SPL Token and Token-2022 account management, transaction construction with instruction composition, RPC batching, and cross-program account coordination. |
| #15 | |
| #16 | ## Anchor Program Initialization |
| #17 | |
| #18 | ```typescript |
| #19 | import { Program, AnchorProvider } from '@coral-xyz/anchor'; |
| #20 | |
| #21 | function getPumpProgram(connection: Connection): Program<Pump> { |
| #22 | const provider = new AnchorProvider( |
| #23 | connection, |
| #24 | { publicKey: PublicKey.default, signTransaction: async (tx) => tx, signAllTransactions: async (txs) => txs }, |
| #25 | { commitment: 'confirmed' } |
| #26 | ); |
| #27 | return new Program(pumpIdl as Pump, PUMP_PROGRAM_ID, provider); |
| #28 | } |
| #29 | ``` |
| #30 | |
| #31 | **Offline pattern:** Uses a dummy provider (no wallet) for building instructions. Actual signing happens in the caller's code. |
| #32 | |
| #33 | ## Instruction Building with `accountsStrict` |
| #34 | |
| #35 | ```typescript |
| #36 | const ix = await program.methods |
| #37 | .buy(amount, maxSolCost, flags) |
| #38 | .accountsStrict({ |
| #39 | global: GLOBAL_PDA, |
| #40 | bondingCurve: bondingCurvePda(mint), |
| #41 | user: userPublicKey, |
| #42 | // ... all required accounts |
| #43 | }) |
| #44 | .remainingAccounts(additionalAccounts) |
| #45 | .instruction(); |
| #46 | ``` |
| #47 | |
| #48 | ## PDA Derivation |
| #49 | |
| #50 | ```typescript |
| #51 | const [pda, bump] = PublicKey.findProgramAddressSync( |
| #52 | [Buffer.from("bonding-curve"), mint.toBuffer()], |
| #53 | PUMP_PROGRAM_ID |
| #54 | ); |
| #55 | ``` |
| #56 | |
| #57 | ## RPC Batching |
| #58 | |
| #59 | ```typescript |
| #60 | const accounts = await connection.getMultipleAccountsInfo([ |
| #61 | bondingCurvePda(mint), |
| #62 | GLOBAL_PDA, |
| #63 | FEE_CONFIG_PDA, |
| #64 | ]); |
| #65 | ``` |
| #66 | |
| #67 | ## Token-2022 Support |
| #68 | |
| #69 | The SDK supports both SPL Token and Token-2022: |
| #70 | - `createV2Instruction` creates Token-2022 mints |
| #71 | - `tokenProgram` parameter selects the appropriate program |
| #72 | - Associated Token Accounts (ATAs) are created idempotently |
| #73 | |
| #74 | ## Account Decoding |
| #75 | |
| #76 | ```typescript |
| #77 | const bondingCurve = program.coder.accounts.decode('bondingCurve', accountInfo.data); |
| #78 | ``` |
| #79 | |
| #80 | Nullable variants handle missing accounts: |
| #81 | ```typescript |
| #82 | const bc = decodeBondingCurveNullable(accountInfo); // returns null instead of throwing |
| #83 | ``` |
| #84 | |
| #85 | ## Transaction Simulation |
| #86 | |
| #87 | ```typescript |
| #88 | const result = await connection.simulateTransaction(tx, [signer]); |
| #89 | // Parse return data from simulation logs |
| #90 | ``` |
| #91 | |
| #92 | ## BN.js Arithmetic |
| #93 | |
| #94 | All amounts use `BN` for arbitrary-precision integer arithmetic: |
| #95 | |
| #96 | ```typescript |
| #97 | const fee = amount.mul(new BN(feeBps)).div(new BN(10000)); |
| #98 | const ceilFee = amount.mul(new BN(feeBps)).add(new BN(9999)).div(new BN(10000)); |
| #99 | ``` |
| #100 | |
| #101 | ## Patterns to Follow |
| #102 | |
| #103 | - Always use `accountsStrict` — not `accounts` — for type-safe account specification |
| #104 | - Use `getMultipleAccountsInfo` to batch account fetches |
| #105 | - Build instruction arrays, not transactions — let callers compose |
| #106 | - Handle both Token and Token-2022 programs via parameter |
| #107 | - Use nullable decoders for optional accounts |
| #108 | |
| #109 | ## Common Pitfalls |
| #110 | |
| #111 | - `AnchorProvider` with dummy wallet is for instruction building only — never sign with it |
| #112 | - `getMultipleAccountsInfo` returns nulls for missing accounts — always check |
| #113 | - Transaction size limit is 1232 bytes — large instruction sets may need multiple transactions |
| #114 | - `remainingAccounts` order matters — the on-chain program reads them positionally |
| #115 | |
| #116 |