This is a micro-indexer built on top of NEAR Lake Framework.
The purpose of this indexer is to watch for every single Transaction
in NEAR Protocol and collect all the children entities related to the Transaction
into a single structure TransactionDetails
.
TODO: Update the README once the structure is finalized.
ref: struct TransactionDetails
The tx-indexer
works like any other Lake-based indexer watching the network.
In order to collect a Transactions
with all related entities it does the following:
- Converts
Transaction
into atx-indexer
-defined structureTransactionDetails
- Stores the data into cache
- Watched for
ExecutionOutcomes
and its statuses. Depending on the status:SuccessValue
means theReceipt
"branch" has finished successfullySuccessReceiptId
means a newReceipt
branch has started and we need to follow it- Other error/failure statuses means the
Receipt
branch has finished with an error
- Whenever we observe a new
Receipt
branch we increment theTransaction
's anticipatedExecutionOutcomes
- Whenever a
Receipt
branch is finishes we decrement theTransaction
's anticipatedExecutionOutcomes
- We add related
Receipts
andExecutionOutcomes
to the corresponding fields of theTransactionDetails
during the indexing - Once the anticipated
ExecutionOutcomes
counter becomes zero we consider theTransactionDetails
collecting as over and can serialize and store in the Storage
An example .env
file:
INDEXER_ID=tx-indexer
DATABASE_URL=127.0.0.1:9042
DATABASE_USER=admin
DATABASE_PASSWORD=password
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_DEFAULT_REGION=eu-central-1
cargo run --release -- <start_options>
start_options
:from-latest
fetches the final block height from the RPC and starts indexing from that blockfrom-interruption <N?>
is used to retrieve thelast_processed_block_height
from the database. This value is used as the starting point for processing blocks. If a specific value<N?>
is provided, it will be used as the fallback option. If<N?>
is not provided or if the database does not have a record (for example, in the case of a fresh start with an empty storage), the fallback option will befrom-latest
.from-block <N>
starts indexing from the block height<N>