diff --git a/.github/workflows/etherscan-apiv2.yml b/.github/workflows/etherscan-apiv2.yml index 063dc6a5583a..a1d2d8e58215 100644 --- a/.github/workflows/etherscan-apiv2.yml +++ b/.github/workflows/etherscan-apiv2.yml @@ -30,6 +30,7 @@ on: - transaction - contract - ens_resolve + - eth_blockNumber ens_name: description: 'ENS name to resolve (default: kushmanmb.eth)' required: false @@ -214,6 +215,13 @@ jobs: DATA="0x70a08231000000000000000000000000${QUERY_ADDRESS#0x}" PARAMS="&to=${RESOLVER_CONTRACT}&data=${DATA}&tag=latest" ;; + "eth_blockNumber") + # Get current Ethereum block number + echo "Fetching current Ethereum block number..." + MODULE="proxy" + ACTION="eth_blockNumber" + PARAMS="" + ;; *) MODULE="account" ACTION="balance" @@ -225,6 +233,13 @@ jobs: echo "Target Address: ${TARGET_ADDRESS}" echo "ENS Name: ${ENS_NAME}" + # Build API URL + if [ "${ENDPOINT}" = "ens_resolve" ] || [ "${ENDPOINT}" = "eth_blockNumber" ]; then + # Use v2 API for proxy calls (matching problem statement) + api_url="https://api.etherscan.io/v2/api?chainid=1&module=${MODULE}&action=${ACTION}${PARAMS}" + else + api_url="${BASE_URL}?module=${MODULE}&action=${ACTION}${PARAMS}" + fi # Build API URL - All endpoints now use V2 API api_url="${BASE_URL}?chainid=1&module=${MODULE}&action=${ACTION}${PARAMS}" diff --git a/ENS_CONFIGURATION.md b/ENS_CONFIGURATION.md index 9e9093346ae5..892322c0a69a 100644 --- a/ENS_CONFIGURATION.md +++ b/ENS_CONFIGURATION.md @@ -28,8 +28,11 @@ console.log('kushmanmb.eth resolves to:', address); #### 2. Via Etherscan API ```bash -# Using Etherscan V2 API with eth_call (as specified in problem statement) +# Using Etherscan V2 API with eth_call curl "https://api.etherscan.io/v2/api?chainid=1&module=proxy&action=eth_call&to=0xAEEF46DB4855E25702F8237E8f403FddcaF931C0&data=0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724&tag=latest&apikey=YourApiKeyToken" + +# Get current Ethereum block number +curl "https://api.etherscan.io/v2/api?chainid=1&module=proxy&action=eth_blockNumber&apikey=YourApiKeyToken" ``` #### 3. Via ENS Registry Contract diff --git a/QUICKSTART_KUSHMANMB_ETH.md b/QUICKSTART_KUSHMANMB_ETH.md index c41f72023e43..270a6018b74b 100644 --- a/QUICKSTART_KUSHMANMB_ETH.md +++ b/QUICKSTART_KUSHMANMB_ETH.md @@ -23,6 +23,7 @@ This guide provides quick instructions for using the kushmanmb.eth ENS integrati - `transaction` - Get transaction history - `contract` - Get contract ABI (if applicable) - `ens_resolve` - Resolve ENS name via eth_call + - `eth_blockNumber` - Get current Ethereum block number - **ENS name**: Keep default `kushmanmb.eth` or enter another ENS name 5. **Click "Run workflow"** green button @@ -36,12 +37,15 @@ The workflow will: 5. Commit and push the data files back to the repository 6. Generate a summary in the workflow run -### Example: Fetching Account Balance +### Example API Calls -The curl command from the problem statement is now integrated: +The following Etherscan API calls are supported: ```bash -# This is automatically executed in the workflow: +# Get current Ethereum block number +curl "https://api.etherscan.io/v2/api?chainid=1&module=proxy&action=eth_blockNumber&apikey=" + +# Query via eth_call (automatically executed in the workflow) curl "https://api.etherscan.io/v2/api?chainid=1&module=proxy&action=eth_call&to=0xAEEF46DB4855E25702F8237E8f403FddcaF931C0&data=0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724&tag=latest&apikey=" ```