View Source Web3.HTTP behaviour (web3ex v0.1.0)

JSONRPC over HTTP

Link to this section Summary

Callbacks

Sends JSONRPC request encoded as iodata/0 to url with options

Link to this section Callbacks

Link to this callback

json_rpc(url, json, options)

View Source
@callback json_rpc(url :: String.t(), json :: iodata(), options :: term()) ::
  {:ok, %{body: body :: String.t(), status_code: status_code :: pos_integer()}}
  | {:error, reason :: term()}

Sends JSONRPC request encoded as iodata/0 to url with options

examples

Examples

iex> request = %{jsonrpc: "2.0", method: "eth_getBalance", params: ["0x1B93C60808449eF4B675caFAca8e7b40999f3fc5", "latest"], id: 1} iex> options = [url: "https://bsc-dataseed4.ninicoin.io/", http: Web3.HTTP.HTTPoison, http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :web3]]] iex> Web3.HTTP.json_rpc(request, options) {:ok, %{}}

iex> request = [%{id: 1, jsonrpc: "2.0", method: "eth_getBalance", params: ["0x1B93C60808449eF4B675caFAca8e7b40999f3fc5", "latest"]}, %{id: 2, jsonrpc: "2.0", method: "eth_blockNumber", params: []}] iex> options = [url: "https://bsc-dataseed4.ninicoin.io/", http: Web3.HTTP.HTTPoison, http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :web3]]] iex> Web3.HTTP.json_rpc(request, options) {:ok, [%{id: 1, result: ""}, %{id: 2, result: ""}]}

Link to this section Functions

Link to this function

json_rpc(request, options)

View Source
Link to this function

standardize_error(unstandardized)

View Source
Link to this function

standardize_response(unstandardized)

View Source