Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

NearApi.RPC.Gas

notebooks/near_api/rpc/gas.livemd

NearApi.RPC.Gas

Setup

System.put_env("NEAR_NODE_URL", "https://rpc.mainnet.near.org")
:ok

NearApi.RPC.Gas.gas_price/1

Returns gas price for a specific block_height or block_hash.

Using no parameters will return the most recent block’s gas price.

Latest gas price

{:ok, result} = NearApi.RPC.Gas.gas_price()
{:ok, %{"id" => "dontcare", "jsonrpc" => "2.0", "result" => %{"gas_price" => "100000000"}}}

Gas price for a specific block

{:ok, %{"result" => %{"gas_price" => gas_price}}} =
  NearApi.RPC.Gas.gas_price("7RVS6t2sdmyAbqM9B9dqxbJiAst24YjaV2fU9Cx2zBsa")
{:ok, %{"id" => "dontcare", "jsonrpc" => "2.0", "result" => %{"gas_price" => "100000000"}}}