NEAR Fetch

General information

Retrieve information from NEAR protocol via NEAR RPC API.

Description

Brick Locations

Bricks Blockchain Connectors → NEAR Fetch

Brick Parameters

  • RPC
    • Select NEAR Protocol networks, each operating with its independent validators and unique state. Users may choose between testnet and mainnet:
    • mainnet - the network which contains production-ready smart contracts and live token transfers.
    • testnet - a final testing network for smart contracts changes before deployment to mainnet
  • Contract / Account Name
    • Address of the smart-contract or account to get information about
  • Request Type
    • RPC API enables users to view details about accounts and contracts as well as perform contract calls to fetch the data. The NEAR Fetch brick supports two types of request types - View Account and Call Function.
  • Method
    • An optional argument should be defined if “Request Type” is “Call Function”.
  • Retry After
    • The time between requests calls in case of fail - 0 by default
  • Number of retries
    • The number of attempts to make a request - 0 by default
  • Arguments
    • Arguments for NEAR fetch Call Function request.
    • Type
      • Static or Dynamic. Static - to submit arguments as JSON, and Dynamic to fill in. arguments from the input data
    • JSON
      • NEAR fetch request’s arguments in case of Static type of the arguments.
       

Brick Inputs/Outputs

  • Inputs
    • Optional. Brick takes the dataset with the request’s arguments when the type of the arguments is Dynamic.
  • Outputs
    • Brick produces the dataset with the NEAR fetch request’s result.

Example of usage

Let’s have a look at the usage of the NEAR Fetch Brick.

Example 1. Get NEAR Balance

For instance, we need to get a NEAR balance for the nearcrowd.near account. In this case we may take NEAR Fetch brick and configure it as:
  • RPC - mainnet
  • Contract / Account name - nearcrowd.near
  • Request Type - View Account
notion image
The result is represented as JSON:
{ "amount": "46462501341544002089168564691", "block_hash": "56cc1iBn1upRF658BHkfUwo6tEWy51wiPCNoH72DgENV", "block_height": 78375288, "code_hash": "11111111111111111111111111111111", "locked": "0", "storage_paid_at": 0, "storage_usage": 7514 }
The information we requested is “amount". We may extract this using Flatten JSON and Math Formula bricks:
 
notion image
 
Math Formula
notion image
Flatten JSON
notion image
 
Finally, we can see that the NEAR balance for nearcrowd.near account is 46’462 NEAR.

Example 2. Get Ref-Finance DEX Pool Liquidity Info

Let’s create the pipeline, which get the actual information about Ref-Finance DEX 1910 Liquidity Pool. This is Stable Swap pool, which contains three tokens - USDT, USDCC and DAI:
notion image
 
To receive the actual information we need to configure the NEAR Fetch brick as:
  • RPC - mainnet
  • Contract / Account name - v2.ref-finance.near
  • Request Type - Call Function
  • Method - get_pool
  • Arguments
    • Type - Static
    • JSON - {”pool_id”: 1910}
 
The result will be looks like
{ "pool_kind": "STABLE_SWAP", "token_account_ids": ["dac17f958d2ee523a2206206994597c13d831ec7.factory.bridge.near", "a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.factory.bridge.near", "6b175474e89094c44da98b954eedeac495271d0f.factory.bridge.near"], "amounts": ["12148943569505", "2209259085575", "3103361205141655518460927"], "total_fee": 5, "shares_total_supply": "17356832827088072001723816", "amp": 240 }
  • pool_kind - the type of the liquidity pool
  • token_account_ids - id off the NEAR accounts that relate to the corresponded fungible tokens
  • amounts - amounts off the corresponded tokens with respect to the decimals of their representation
  • total_fee - total liquidity pool swap fee
  • shares_total_supply - the total liquidity pool shares
  • amp - amp factor, algorithm parameter, decide how stable the pool will be

Example 3. Get Information about several Ref-Finance DEX Liquidity Pools

We may create pipeline, which returns the informations about several Liquidity pools by using NEAR Fetch brick inside For-Loop brick
notion image
notion image
Create New Column
notion image
Create New Column
notion image
Filter Column
notion image
Prepare JSON
notion image
Parse List
notion image
Apply Function
notion image
NEAR Fetch
notion image
 
The result will be represented as Dataframe with JSON structures:
notion image

DEMO Pipeline