Filter Transactions
The map_filter_transactions
module of the Solana Substreams Explorer filters transactions given a signature hash. For example, let's consider that you want to retrieve transactions containing the 21ED2HBGuLUwgbaBb77cGwFR8MkVQfjR9KszzCb7jZkeSysJkHAVew6RaaBh3r1zTefpdq9Kf5geFp19P3nUXB3t
.
Run the Substreams
Run From Source Code
In the substreams-explorer
project, move to the solana-explorer
folder, which contains the source of the Solana Substreams. Then, build the Rust code:
Now, you can run the Substreams by using the substreams gui
command. To avoid iterating over the whole blockchain, the following command extracts transactions including 21ED2HBGuLUwgbaBb77cGwFR8MkVQfjR9KszzCb7jZkeSysJkHAVew6RaaBh3r1zTefpdq9Kf5geFp19P3nUXB3t
signatures.
In the Output
screen of the Substreams GUI you can see there is a transaction with the corresponding signature at block number 153000028
.
You can change the signature hash in params
section of the the Substreams Manifest (substreams.yaml
):
Run the Package From the Substreams Registry
The Solana Explorer is also available as a Substreams package in the Substreams Regitry. You can simply run it:
Inspect the Code
The map_flter_transaction.rs
file contains the source of the module. The output emitted by the module is defined as a Protobuf in the /proto/transactions.proto
file of the project.
The output of the Substreams is the Transactions
Protobuf object:
Parse the filters provided as a parameter to the module function. The signature to filter is defined as a parameter in the Substreams Manifest, and is then injected as a string in the Rust function.
Iterate over the transactions of the block.
Filter the transactions by invoking the
apply_filters
function. This function only keeps transactions containing the signature passed as a parameter.Get the accounts of the transaction. The
resolved_accounts()
method includes accounts stored in the Address Lookup Tables.Iterate over the instructions of the transaction.
Map every instruction to the
Instruction
output Protobuf data model of the Substreams, keeping only three fields:program_id
,accounts
anddata
.Map the transaction to the
Transaction
output Protobuf data model of the Substreams.
Last updated