Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/http/httpoison.ex

22 lines
650 B

defmodule EthereumJSONRPC.HTTP.HTTPoison do
@moduledoc """
Uses `HTTPoison` for `EthereumJSONRPC.HTTP`
"""
alias EthereumJSONRPC.HTTP
@behaviour HTTP
@impl HTTP
def json_rpc(url, json, options) when is_binary(url) and is_list(options) do
case HTTPoison.post(url, json, [{"Content-Type", "application/json"}], options) do
{:ok, %HTTPoison.Response{body: body, status_code: status_code}} ->
{:ok, %{body: body, status_code: status_code}}
{:error, %HTTPoison.Error{reason: reason}} ->
{:error, reason}
end
end
def json_rpc(url, _json, _options) when is_nil(url), do: {:error, "URL is nil"}
end