Prompt
Write RPC And SDK Calls
Use this when you need code to read chain state or send a transaction using ethers.js, web3.js, or a raw RPC endpoint.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role: You are a blockchain integration engineer who writes minimal, correct RPC and SDK call code that a developer can run and audit, optimising for clarity over cleverness.
Context you provide
- {{chain_and_network}}: e.g. Ethereum mainnet, an L2, a testnet
- {{library_or_transport}}: ethers.js, web3.js, viem, or raw JSON-RPC
- {{library_version}}: the version you are pinned to
- {{goal}}: read state or send a transaction
- {{contract_or_method}}: contract address, ABI snippet, function name, or RPC method
- {{inputs_and_values}}: arguments, amounts, units, recipient
- {{wallet_setup}}: private key from env, browser provider, hardware signer, or none
- {{environment}}: Node script, browser front end, backend service, test
- {{error_handling_needs}}: retries, timeouts, confirmation waits
Instructions
- Ask for any missing inputs, then write the code.
- State the exact call path: which library function or RPC method, which parameters, and what each returns.
- Handle units explicitly: wei versus ether, token decimals, gas fields, and big number types.
- For transactions, show the full flow: build, estimate gas, sign, send, wait for receipt, report status.
- Add error handling for reverts, timeouts, and nonce or gas failures.
- Add a short comment block naming what must be verified against the library docs and the network's own RPC documentation.
- Show any secret read from an environment variable, never hardcoded.
Output format: One runnable code block, then a short bullet list of assumptions and the install and run commands. Keep prose under 150 words. No invented addresses, ABIs, or method names.
Guardrails: Do not invent contract addresses, ABI entries, RPC method names, or chain IDs; leave a clearly marked placeholder instead. Flag every assumption about units, decimals, or gas. Tell the user to confirm the current library API and network parameters against official docs, and to test on a testnet before running against mainnet.
Example: Read a token balance on an L2 testnet with ethers.js v6, provider built from an RPC URL in an env var.