2021-11-05 13:55:48 +00:00
|
|
|
import json, strutils, strformat
|
|
|
|
import ./core, ./response_type
|
|
|
|
|
|
|
|
export response_type
|
|
|
|
|
|
|
|
proc getAccounts*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
|
|
return core.callPrivateRPC("eth_accounts")
|
|
|
|
|
|
|
|
proc getBlockByNumber*(blockNumber: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
|
|
let payload = %* [blockNumber, false]
|
|
|
|
return core.callPrivateRPC("eth_getBlockByNumber", payload)
|
|
|
|
|
|
|
|
proc getEthBalance*(address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
|
|
let payload = %* [address, "latest"]
|
|
|
|
return core.callPrivateRPC("eth_getBalance", payload)
|
|
|
|
|
2021-10-27 20:09:36 +00:00
|
|
|
proc call*(payload = %* []): RpcResponse[JsonNode] {.raises: [Exception].} =
|
|
|
|
return core.callPrivateRPC("eth_call", payload)
|