github.com/lmittmann/w3@v0.20.0/docs/pages/rpc-methods/eth.mdx (about) 1 # `eth`-Namespace 2 3 List of supported RPC methods for `w3.Client` in the `eth`-namespace. 4 5 ## `eth_blockNumber` 6 `BlockNumber` requests the number of the most recent block. 7 ```go {3} 8 var blockNumber *big.Int 9 client.Call( 10 eth.BlockNumber().Returns(&blockNumber), 11 ) 12 ``` 13 14 ## `eth_call` 15 `Call` requests the output data of the given message at the given blockNumber. If blockNumber is nil, the output of the message at the latest known block is requested. 16 ```go {3} 17 var output []byte 18 client.Call( 19 eth.Call(msg, blockNumber, overrides).Returns(&output), 20 ) 21 ``` 22 23 ## `eth_chainId` 24 `ChainID` requests the chains ID. 25 ```go {3} 26 var chainID uint64 27 client.Call( 28 eth.ChainID().Returns(&chainID), 29 ) 30 ``` 31 32 ## `eth_createAccessList` 33 `AccessList` requests the access list of the given message at the given blockNumber. If blockNumber is nil, the access list of the message at the latest block is requested. 34 ```go {3} 35 var accessListResp *AccessListResponse 36 client.Call( 37 eth.AccessList(msg, blockNumber).Returns(&accessListResp), 38 ) 39 ``` 40 41 ## `eth_estimateGas` 42 `EstimateGas` requests the estimated gas cost of the given message at the given blockNumber. If blockNumber is nil, the estimated gas cost of the message at the latest block is requested. 43 ```go {3} 44 var gas uint64 45 client.Call( 46 eth.EstimateGas(msg, blockNumber).Returns(&gas), 47 ) 48 ``` 49 50 ## `eth_gasPrice` 51 `GasPrice` requests the current gas price in wei. 52 ```go {3} 53 var gasPrice *big.Int 54 client.Call( 55 eth.GasPrice().Returns(&gasPrice), 56 ) 57 ``` 58 59 ## `eth_maxPriorityFeePerGas` 60 `GasTipCap` requests the currently suggested gas tip cap after EIP-1559 to allow a timely execution of a transaction. 61 ```go {3} 62 var gasTipCap *big.Int 63 client.Call( 64 eth.GasTipCap().Returns(&gasTipCap), 65 ) 66 ``` 67 68 ## `eth_getBalance` 69 `Balance` requests the balance of the given common.Address addr at the given blockNumber. If blockNumber is nil, the balance at the latest known block is requested. 70 ```go {3} 71 var balance *big.Int 72 client.Call( 73 eth.Balance(addr, blockNumber).Returns(&balance), 74 ) 75 ``` 76 77 ## `eth_getBlockByHash` 78 `BlockByHash` requests the block with the given hash with full transactions. 79 ```go {3} 80 var block *types.Block 81 client.Call( 82 eth.BlockByHash(hash).Returns(&block), 83 ) 84 ``` 85 86 ## `eth_getBlockByNumber` 87 `BlockByNumber` requests the block with the given number with full transactions. If number is nil, the latest block is requested. 88 ```go {3} 89 var block *types.Block 90 client.Call( 91 eth.BlockByNumber(number).Returns(&block), 92 ) 93 ``` 94 95 ## `eth_getBlockReceipts` 96 `BlockReceipts` requests all receipts of the transactions in the given block. 97 ```go {3} 98 var receipts types.Receipts 99 client.Call( 100 eth.BlockReceipts(blockNumber).Returns(&receipts), 101 ) 102 ``` 103 104 ## `eth_getBlockTransactionCountByHash` 105 `BlockTxCountByHash` requests the number of transactions in the block with the given hash. 106 ```go {3} 107 var count uint 108 client.Call( 109 eth.BlockTxCountByHash(hash).Returns(&count), 110 ) 111 ``` 112 113 ## `eth_getBlockTransactionCountByNumber` 114 `BlockTxCountByNumber` requests the number of transactions in the block with the given number. 115 ```go {3} 116 var count uint 117 client.Call( 118 eth.BlockTxCountByNumber(number).Returns(&count), 119 ) 120 ``` 121 122 ## `eth_getCode` 123 `Code` requests the code of the given common.Address addr at the given blockNumber. If blockNumber is nil, the code at the latest known block is requested. 124 ```go {3} 125 var code []byte 126 client.Call( 127 eth.Code(addr, blockNumber).Returns(&code), 128 ) 129 ``` 130 131 ## `eth_getLogs` 132 `Logs` requests the logs of the given ethereum.FilterQuery q. 133 ```go {3} 134 var logs []types.Log 135 client.Call( 136 eth.Logs(query).Returns(&logs), 137 ) 138 ``` 139 140 ## `eth_getStorageAt` 141 `StorageAt` requests the storage of the given common.Address addr at the given common.Hash slot at the given blockNumber. If block number is nil, the slot at the latest known block is requested. 142 ```go {3} 143 var storage common.Hash 144 client.Call( 145 eth.StorageAt(addr, slot, blockNumber).Returns(&storage), 146 ) 147 ``` 148 149 ## `eth_getTransactionByHash` 150 `Tx` requests the transaction with the given hash. 151 ```go {3} 152 var tx *types.Transaction 153 client.Call( 154 eth.Tx(hash).Returns(&tx), 155 ) 156 ``` 157 158 ## `eth_getTransactionByBlockHashAndIndex` 159 `TxByBlockHashAndIndex` requests the transaction in the given block with the given index. 160 ```go {3} 161 var tx *types.Transaction 162 client.Call( 163 eth.TxByBlockHashAndIndex(blockHash, index).Returns(&tx), 164 ) 165 ``` 166 167 ## `eth_getTransactionByBlockNumberAndIndex` 168 `TxByBlockNumberAndIndex` requests the transaction in the given block with the given index. 169 ```go {3} 170 var tx *types.Transaction 171 client.Call( 172 eth.TxByBlockNumberAndIndex(blockNumber, index).Returns(&tx), 173 ) 174 ``` 175 ## `eth_getTransactionCount` 176 `Nonce` requests the nonce of the given common.Address addr at the given blockNumber. If blockNumber is nil, the nonce at the latest known block is requested. 177 ```go {3} 178 var count uint 179 client.Call( 180 eth.Nonce(addr, blockHash).Returns(&count), 181 ) 182 ``` 183 184 ## `eth_getTransactionReceipt` 185 `TxReceipt` requests the receipt of the transaction with the given hash. 186 ```go {3} 187 var receipt *types.Receipt 188 client.Call( 189 eth.TxReceipt(txHash).Returns(&receipt), 190 ) 191 ``` 192 193 ## `eth_sendRawTransaction` 194 `SendRawTx` sends a raw transaction to the network and returns its hash. 195 ```go {3} 196 var txHash common.Hash 197 client.Call( 198 eth.SendRawTx(rawTx).Returns(&txHash), 199 ) 200 ``` 201 202 SendTx sends a signed transaction to the network and returns its hash. 203 ```go {3} 204 var txHash common.Hash 205 client.Call( 206 eth.SendTx(tx).Returns(&txHash), 207 ) 208 ``` 209 210 ## `eth_getUncleByBlockHashAndIndex` 211 `UncleByBlockHashAndIndex` requests the uncle of the block with the given hash at the given index. 212 ```go {3} 213 var uncle *types.Header 214 client.Call( 215 eth.UncleByBlockHashAndIndex(hash, index).Returns(&uncle), 216 ) 217 ``` 218 219 ## `eth_getUncleByBlockNumberAndIndex` 220 `UncleByBlockNumberAndIndex` requests the uncle of the block with the given number at the given index. 221 ```go {3} 222 var uncle *types.Header 223 client.Call( 224 eth.UncleByBlockNumberAndIndex(number, index).Returns(&uncle), 225 ) 226 ``` 227 ## `eth_getUncleCountByBlockHash` 228 `UncleCountByBlockHash` requests the number of uncles of the block with the given hash. 229 ```go {3} 230 var count uint 231 client.Call( 232 eth.UncleCountByBlockHash(hash).Returns(&count), 233 ) 234 ``` 235 236 ## `eth_getUncleCountByBlockNumber` 237 `UncleCountByBlockNumber` requests the number of uncles of the block with the given number. 238 ```go {3} 239 var count uint 240 client.Call( 241 eth.UncleCountByBlockNumber(number).Returns(&count), 242 ) 243 ``` 244 245 ## `eth_syncing` 246 `Syncing` requests the syncing status of the node. 247 ```go {3} 248 var syncing bool 249 client.Call( 250 eth.Syncing().Returns(&syncing), 251 ) 252 ```