Back to list
tradingstrategy-ai

get-block-number

by tradingstrategy-ai

A Python library for trading automation on DeFi, data research and integration. Supporting Uniswap, Aave, Chainlink, USDC and other protocols.

770🍴 175📅 Jan 23, 2026

SKILL.md


name: get-block-number description: Get the latest block number for a blockchain using Web3.py and JSON-RPC environment variables

Get latest block number

This skill retrieves the latest block number from a blockchain using the configured JSON-RPC environment variables and Web3.py.

ALWAYS USE SCRIPT. NEVER RELY ON THE HISTORICAL INFORMATION OR GUESS.

Required inputs

  1. Chain name: The blockchain to query (e.g., Ethereum, Arbitrum, Base, Polygon)

Running the script

Generate and run a Python script to fetch the block number. Run it Python commadn line inline, don't write a new file.

import os
from web3 import Web3

from eth_defi.provider.multi_provider import create_multi_provider_web3

# Replace {CHAIN} with the uppercase chain name
json_rpc_url = os.environ.get("JSON_RPC_{CHAIN}")

if not json_rpc_url:
    raise ValueError("JSON_RPC_{CHAIN} environment variable not set")

web3 = create_multi_provider_web3(json_rpc_url)
block_number = web3.eth.block_number

print(f"Latest block number: {block_number}")

Run the script with:

source .local-test.env && poetry run python <script_path>

Display output

Return the block number to the user in a clear format, e.g.:

Chain: Ethereum
Latest block number: 19,234,567

Score

Total Score

90/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 500以上

+10
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon