Course overview
Lesson 5 of 9 · 3 promptsAI for Blockchain Developers
LESSON 05 OF 9

Integrating Blockchain APIs

3 prompts for Blockchain Developers

Prompts for Blockchain Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Write RPC And SDK CallsUse this when you need code to read chain state or send a transaction using ethers.js, web3.js, or a raw RPC endpoint.
  2. 02Draft a Subgraph GraphQL QueryUse this when you want historical or aggregated on-chain data and need a GraphQL or indexer query drafted.
  3. 03Add Wallet Connection To A dAppUse this when you need frontend code to connect MetaMask or WalletConnect and handle account and chain changes.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

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.

Prompt

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

  1. Ask for any missing inputs, then write the code.
  2. State the exact call path: which library function or RPC method, which parameters, and what each returns.
  3. Handle units explicitly: wei versus ether, token decimals, gas fields, and big number types.
  4. For transactions, show the full flow: build, estimate gas, sign, send, wait for receipt, report status.
  5. Add error handling for reverts, timeouts, and nonce or gas failures.
  6. Add a short comment block naming what must be verified against the library docs and the network's own RPC documentation.
  7. 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.

Open as its own page

02

Draft a Subgraph GraphQL Query

Use this when you want historical or aggregated on-chain data and need a GraphQL or indexer query drafted.

Prompt

Role: You are a blockchain data engineer who writes subgraph GraphQL queries against indexed on-chain data. You optimise for queries that run without errors and return exactly the fields the user asked for.

Context you provide

  • {{subgraph_schema}}: the entity types and fields available, pasted from the schema
  • {{subgraph_name_or_url}}: the deployment name or endpoint you query
  • {{network}}: the chain the subgraph indexes
  • {{question_to_answer}}: the business or analytics question
  • {{filters}}: time range, addresses, token pairs, thresholds
  • {{output_shape}}: table, JSON payload, or chart-ready series
  • {{query_style}}: single lookup, paginated list, or time-bucketed aggregate

Instructions

  1. Ask for any missing inputs, then confirm the entity and field names you will use.
  2. Map the question to entities and fields in the schema. If a needed field is absent, say so before writing anything.
  3. Draft the query with explicit field selections, filters, ordering, and a sensible first/skip or timestamp range.
  4. For aggregates, use the subgraph's aggregation entities or bucket by time interval and explain the bucketing.
  5. Add pagination or cursor guidance if the result set can exceed one page.
  6. Show how to run it: endpoint, method, and a minimal request body or CLI example.
  7. Note any indexer limits, indexing lag, or rate limits that affect the result.

Output format One GraphQL query in a fenced code block, followed by a short bullet list: fields used and why, pagination notes, and the run command. Keep prose under 200 words. Skip GraphQL basics.

Guardrails

  • Only use entity and field names present in {{subgraph_schema}}. Never invent fields, endpoints, or IDs.
  • If the subgraph does not index the data needed, say so and suggest what to query instead, such as raw logs or an archive node.
  • Flag that indexed data can lag the chain head and that results are not financial advice.

Example {{subgraph_schema}} = pool, swap, token entities; {{question_to_answer}} = daily swap volume for one pool over 30 days; {{filters}} = pool address, last 30 days; {{output_shape}} = chart-ready series.

Open as its own page

03

Add Wallet Connection To A dApp

Use this when you need frontend code to connect MetaMask or WalletConnect and handle account and chain changes.

Prompt

Role You are a frontend blockchain engineer writing wallet connection code for decentralized apps. You optimise for code that works across MetaMask and WalletConnect and reacts correctly when the account or chain changes.

Context you provide

  • {{framework_and_version}} — e.g. React 18 with Vite
  • {{wallet_library}} — e.g. wagmi with viem, or ethers v6
  • {{target_wallets}} — MetaMask, WalletConnect, others
  • {{supported_chains}} — names and IDs you support
  • {{existing_wallet_code}} — paste current connect logic, or "none"
  • {{ui_stack}} — Tailwind, plain CSS, component library
  • {{persist_session}} — should the connection survive a reload
  • {{error_cases_to_cover}} — user rejection, no wallet, wrong network

Instructions

  1. Ask for any missing inputs, then summarise the connection flow in three lines.
  2. Write connect, disconnect and read-account functions with {{wallet_library}}.
  3. Subscribe to account and chain change events and drive UI state from them.
  4. Add a wrong-network guard that offers a switch to a chain in {{supported_chains}}.
  5. Handle each case in {{error_cases_to_cover}} with a clear user-facing message.
  6. List the manual browser tests the developer should run.

Output format Code blocks with file paths and short inline comments, plus one brief note per event handler. No long prose and no extra app scaffolding.

Guardrails

  • Do not invent chain IDs, RPC URLs or contract addresses; ask the user to confirm each.
  • WalletConnect needs a project ID from the user's own dashboard; say so instead of supplying one.
  • Tell the user to check the wallet provider's current docs, since wallet APIs change.

Example React 18 with Vite, wagmi and viem, MetaMask plus WalletConnect, Ethereum mainnet and Sepolia, no existing code, Tailwind, persist session, cover user rejection and wrong network.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.