Skip to main content

NEAR Indexer for Explorer

While developing a decentralized app you might want to query usage information for a contract such as:

  1. Which users have called a specific method in my contract?
  2. How much money and gas did they deposit?
  3. Which transactions failed?

In order to simplify asking these questions is that we developed the NEAR Indexer for Explorer. The NEAR Indexer for Explorer is a public-access read-only PostgreSQL database where all blockchain actions are stored.

danger

The database could go down or take time to reflect the most current blockchain info. Do not use it in production. For a reliable source of real time and past information, please run your own indexer.


Connecting to the Databaseโ€‹

You can use any database manager compatible with PostgreSQL. If you don't know any, we can recommend you to try DBeaver Community.

NetworkHostPortDatabaseUsernamePassword
mainnetmainnet.db.explorer.indexer.near.dev5432mainnet_explorerpublic_readonlynearprotocol
testnettestnet.db.explorer.indexer.near.dev5432testnet_explorerpublic_readonlynearprotocol

Database Structureโ€‹

Please bear in mind that the structure might evolve or change with time.

structure_img


Example Queriesโ€‹

Transactions Calling a Methodโ€‹

Query for all transaction that called contribute in the v1.faucet.nonofficial.testnet testnet account.

select r.predecessor_account_id, t.transaction_hash 
from receipts r, action_receipt_actions ara, transactions t
where r.receiver_account_id ='v1.faucet.nonofficial.testnet'
and ara.receipt_id = r.receipt_id
and ara.action_kind = 'FUNCTION_CALL'
and ara.args @> '{"method_name": "contribute"}'
and t.transaction_hash = r.originated_from_transaction_hash

Users, Status and Attached Moneyโ€‹

Query for all users that called contribute in v1.faucet.nonofficial.testnet, how much they attached to the call, and the transaction status.

select t.transaction_hash, eo.status, r.predecessor_account_id , ara.args -> 'deposit' as deposit
from receipts r, action_receipt_actions ara, transactions t, execution_outcomes eo
where r.receiver_account_id ='v1.faucet.nonofficial.testnet'
and ara.receipt_id = r.receipt_id and ara.action_kind = 'FUNCTION_CALL'
and ara.args @> '{"method_name": "contribute"}'
and t.transaction_hash = r.originated_from_transaction_hash
and r.receipt_id = eo.receipt_id

Sent Moneyโ€‹

Query for all the transfers going out from v1.faucet.nonofficial.testnet.

select r.receiver_account_id, ara.args -> 'deposit' as deposit  
from receipts r, action_receipt_actions ara
where r.predecessor_account_id ='v1.faucet.nonofficial.testnet'
and ara.receipt_id = r.receipt_id and ara.action_kind = 'TRANSFER'