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:
The information we requested is “amount". We may extract this using Flatten JSON and Math Formula bricks:
Math Formula
Flatten JSON
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:
To receive the actual information we need to configure the NEAR Fetch brick as: