MCPcopy Create free account
hub / github.com/GridPlus/client / Eth_getBlockByHash

Method Eth_getBlockByHash

src/rpc/web3.go:420–446  ·  view source on GitHub ↗

Eth_getBlockByHash calls the eth_getBlockByHash JSON-RPC method

(blockHash string, full bool)

Source from the content-addressed store, hash-verified

418
419// Eth_getBlockByHash calls the eth_getBlockByHash JSON-RPC method
420func (client *EthereumClient) Eth_getBlockByHash(blockHash string, full bool) (*Block, error) {
421
422 reqBody := JSONRPCRequest{
423 JSONRPC: "2.0",
424 ID: 1,
425 Method: "eth_getBlockByHash",
426 Params: []interface{}{blockHash, full},
427 }
428
429 body, err := client.issueRequest(&reqBody)
430 if err != nil {
431 return nil, err
432 }
433
434 var clientResp BlockResponse
435 err = json.Unmarshal(body, &clientResp)
436 if err != nil {
437 return nil, err
438 }
439
440 block, err := clientResp.Result.ToBlock()
441 if err != nil {
442 return nil, err
443 }
444
445 return block, nil
446}
447
448// Eth_getTransactionByHash calls the eth_getTransactionByHash JSON-RPC method
449func (client *EthereumClient) Eth_getTransactionByHash(txHash string) (TransactionResult, error) {

Callers

nothing calls this directly

Calls 2

issueRequestMethod · 0.95
ToBlockMethod · 0.80

Tested by

no test coverage detected