jpskill.com
🛠️ 開発・MCP コミュニティ

web3-py

Python library for interacting with Ethereum blockchain via Web3 protocols.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o web3-py.zip https://jpskill.com/download/22038.zip && unzip -o web3-py.zip && rm web3-py.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/22038.zip -OutFile "$d\web3-py.zip"; Expand-Archive "$d\web3-py.zip" -DestinationPath $d -Force; ri "$d\web3-py.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して web3-py.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → web3-py フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

web3-py

Purpose

web3-py is a Python library for interacting with the Ethereum blockchain using Web3 protocols. It enables programmatic access to blockchain data, smart contracts, and transactions.

When to Use

Use this skill when building Python applications that need to query Ethereum data, deploy smart contracts, or handle transactions. Applicable for dApps, blockchain analytics, or automated scripts interacting with Ethereum nodes.

Key Capabilities

  • Connect to Ethereum nodes via HTTP, WebSocket, or IPC providers.
  • Manage accounts, sign transactions, and handle gas estimates.
  • Interact with smart contracts using ABI definitions.
  • Query blockchain state, including balances, blocks, and events.
  • Support for Ethereum-compatible chains like Binance Smart Chain.

Usage Patterns

Always import web3-py and initialize a Web3 instance with a provider. Use environment variables for sensitive keys, e.g., set INFURA_API_KEY in your shell. Structure code to handle asynchronous operations with web3.async for better performance. For production, wrap calls in try-except blocks and use a reliable provider URL.

Common Commands/API

  • To get an account balance: Use web3.eth.get_balance(address). Example:
    from web3 import Web3
    w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/' + os.getenv('INFURA_API_KEY')))
    balance = w3.eth.get_balance('0xYourAddress')
  • To send a transaction: Use w3.eth.send_transaction(transaction). Example:
    tx = {'from': account.address, 'to': '0xRecipient', 'value': w3.to_wei(1, 'ether')}
    signed_tx = w3.eth.account.sign_transaction(tx, private_key=os.getenv('ETH_PRIVATE_KEY'))
    tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
  • To call a smart contract function: Use contract.functions.myFunction().call(). Example:
    contract = w3.eth.contract(address='0xContractAddress', abi=contract_abi)
    result = contract.functions.balanceOf('0xAddress').call()
  • To estimate gas: Use w3.eth.estimate_gas(transaction). Pass a dictionary with 'from', 'to', and 'data' keys.

Integration Notes

Integrate web3-py by installing via pip install web3. Configure providers with URLs like https://mainnet.infura.io/v3/$INFURA_API_KEY for Infura. Use env vars for keys: e.g., os.getenv('INFURA_API_KEY') for API access. For local nodes, use IPC: Web3(Web3.IPCProvider('/path/to/geth.ipc')). Ensure compatibility with Ethereum versions; specify chain ID in transactions to prevent replay attacks. Test integrations in a sandbox like Ganache before production.

Error Handling

Handle connection errors with try-except for ConnectionError, e.g.:

try:
    w3.eth.get_block('latest')
except web3.exceptions.ConnectionError:
    print("Node unreachable; check provider URL and network status.")

For transaction failures, catch ValueError for insufficient funds or gas issues:

try:
    tx_hash = w3.eth.send_transaction(tx)
except ValueError as e:
    if 'insufficient funds' in str(e):
        raise Exception("Add funds to account before retrying.")

Validate inputs like addresses with w3.is_address(address) before use. Log errors with details like error codes (e.g., RPC errors from providers) for debugging.

Concrete Usage Examples

  1. Querying token balance: To get the ERC-20 balance of an address on Ethereum mainnet, initialize Web3 with Infura, load the token contract, and call the balanceOf function. Example usage in a script: Set INFURA_API_KEY env var, then run the snippet above under Common Commands/API for contract calls.
  2. Deploying a simple smart contract: Compile a Solidity contract to ABI and bytecode, then use w3.eth.contract to deploy. Example: In code, create a contract instance and send a transaction with the bytecode, handling gas limits as shown in the send_transaction example.

Graph Relationships

  • Related to cluster: blockchain (e.g., shares capabilities with other blockchain tools).
  • Connected to tags: web3 (direct API interactions), python (Python-based implementation), ethereum (specific to Ethereum ecosystem).
  • Links to: smart-contracts (via contract handling features), as indicated in embedding hint.