$npx -y skills add AlexAI-MCP/hermes-CCC --skill base-blockchainQuery Base (Ethereum L2) blockchain data — wallet balances, token info, transactions, gas analysis, contract inspection. No API key required.
| 1 | # Base Blockchain |
| 2 | |
| 3 | Query Base (Ethereum L2) on-chain data enriched with USD pricing. No API key needed — uses public RPC + CoinGecko. |
| 4 | |
| 5 | ## Base RPC Endpoints |
| 6 | |
| 7 | ``` |
| 8 | Mainnet: https://mainnet.base.org |
| 9 | Testnet: https://sepolia.base.org |
| 10 | Chain ID: 8453 (mainnet) / 84532 (testnet) |
| 11 | ``` |
| 12 | |
| 13 | ## Python Setup |
| 14 | |
| 15 | ```python |
| 16 | import urllib.request, json |
| 17 | |
| 18 | RPC = "https://mainnet.base.org" |
| 19 | |
| 20 | def rpc_call(method, params=[]): |
| 21 | payload = json.dumps({"jsonrpc":"2.0","method":method,"params":params,"id":1}).encode() |
| 22 | req = urllib.request.Request(RPC, data=payload, headers={"Content-Type":"application/json"}) |
| 23 | with urllib.request.urlopen(req) as r: |
| 24 | return json.loads(r.read())["result"] |
| 25 | ``` |
| 26 | |
| 27 | --- |
| 28 | |
| 29 | ## Wallet Balance |
| 30 | |
| 31 | ```python |
| 32 | def get_eth_balance(address): |
| 33 | hex_balance = rpc_call("eth_getBalance", [address, "latest"]) |
| 34 | return int(hex_balance, 16) / 1e18 |
| 35 | |
| 36 | addr = "0xYourWalletAddress" |
| 37 | print(f"Balance: {get_eth_balance(addr):.6f} ETH") |
| 38 | ``` |
| 39 | |
| 40 | --- |
| 41 | |
| 42 | ## ERC-20 Token Balance |
| 43 | |
| 44 | ```python |
| 45 | # balanceOf(address) = keccak256 first 4 bytes = 0x70a08231 |
| 46 | def get_token_balance(token_addr, wallet_addr, decimals=18): |
| 47 | data = "0x70a08231" + wallet_addr[2:].zfill(64) |
| 48 | result = rpc_call("eth_call", [{"to": token_addr, "data": data}, "latest"]) |
| 49 | return int(result, 16) / (10 ** decimals) |
| 50 | |
| 51 | # USDC on Base (6 decimals) |
| 52 | usdc = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" |
| 53 | print(f"USDC: {get_token_balance(usdc, addr, decimals=6):.2f}") |
| 54 | ``` |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## Transaction Details |
| 59 | |
| 60 | ```python |
| 61 | def get_tx(tx_hash): |
| 62 | return rpc_call("eth_getTransactionByHash", [tx_hash]) |
| 63 | |
| 64 | def get_tx_receipt(tx_hash): |
| 65 | return rpc_call("eth_getTransactionReceipt", [tx_hash]) |
| 66 | |
| 67 | tx = get_tx("0xabc123...") |
| 68 | print(f"From: {tx['from']}") |
| 69 | print(f"To: {tx['to']}") |
| 70 | print(f"Value: {int(tx['value'],16)/1e18} ETH") |
| 71 | ``` |
| 72 | |
| 73 | --- |
| 74 | |
| 75 | ## Gas Analysis |
| 76 | |
| 77 | ```python |
| 78 | def get_gas_price(): |
| 79 | hex_gas = rpc_call("eth_gasPrice") |
| 80 | gwei = int(hex_gas, 16) / 1e9 |
| 81 | return gwei |
| 82 | |
| 83 | print(f"Gas price: {get_gas_price():.2f} Gwei") |
| 84 | |
| 85 | # Estimate gas for a transfer |
| 86 | def estimate_gas(from_addr, to_addr, value_eth): |
| 87 | return rpc_call("eth_estimateGas", [{ |
| 88 | "from": from_addr, |
| 89 | "to": to_addr, |
| 90 | "value": hex(int(value_eth * 1e18)) |
| 91 | }]) |
| 92 | ``` |
| 93 | |
| 94 | --- |
| 95 | |
| 96 | ## ETH Price (CoinGecko) |
| 97 | |
| 98 | ```python |
| 99 | def get_eth_price_usd(): |
| 100 | url = "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd" |
| 101 | with urllib.request.urlopen(url) as r: |
| 102 | return json.loads(r.read())["ethereum"]["usd"] |
| 103 | |
| 104 | price = get_eth_price_usd() |
| 105 | balance = get_eth_balance(addr) |
| 106 | print(f"Portfolio: ${balance * price:.2f} USD") |
| 107 | ``` |
| 108 | |
| 109 | --- |
| 110 | |
| 111 | ## Block Info |
| 112 | |
| 113 | ```python |
| 114 | def get_latest_block(): |
| 115 | return rpc_call("eth_getBlockByNumber", ["latest", False]) |
| 116 | |
| 117 | block = get_latest_block() |
| 118 | print(f"Block: {int(block['number'],16)}") |
| 119 | print(f"Txs: {len(block['transactions'])}") |
| 120 | ``` |
| 121 | |
| 122 | --- |
| 123 | |
| 124 | ## Contract Inspection |
| 125 | |
| 126 | ```python |
| 127 | # Check if address is a contract |
| 128 | def is_contract(address): |
| 129 | code = rpc_call("eth_getCode", [address, "latest"]) |
| 130 | return code != "0x" |
| 131 | |
| 132 | # Read contract storage slot |
| 133 | def get_storage(address, slot): |
| 134 | return rpc_call("eth_getStorageAt", [address, hex(slot), "latest"]) |
| 135 | ``` |
| 136 | |
| 137 | --- |
| 138 | |
| 139 | ## Basescan API (optional) |
| 140 | |
| 141 | For detailed tx history, use Basescan API (free key at basescan.org): |
| 142 | ```python |
| 143 | BASESCAN = "https://api.basescan.org/api" |
| 144 | # Get tx list for address |
| 145 | params = f"?module=account&action=txlist&address={addr}&apikey=YOUR_KEY" |
| 146 | ``` |