Explorer and Indexer
The next step is to be able to see what is actually happening in your blockchain. One easy way to do this is to use Blockscout (opens new window).
# Prerequisites
# Archive mode
Blockscout expects to interact with an Ethereum execution client in archive mode (opens new window).
If your op-geth
is running in full mode, you can create a separate archive node.
To do so, follow the directions to add a node, but in the command you use to start op-geth
replace:
--gcmode=full \
with
--gcmode=archive \
# Docker
The easiest way to run Blockscout is to use Docker. Download and install Docker engine (opens new window).
# Installation and configuration
Clone the Blockscout repository.
cd ~ git clone https://github.com/blockscout/blockscout.git cd blockscout/docker-compose
1
2
3Depending on the version of Docker you have, there may be an issue with the environment path. Run this command to fix it:
ln -s `pwd`/envs ..
1If
op-geth
in archive mode runs on a different computer or a port that isn't 8545, editdocker-compose-no-build-geth.yml
to setETHEREUM_JSONRPC_HTTP_URL
to the correct URL.Start Blockscout
docker compose -f docker-compose-no-build-geth.yml up
1
# Usage
After the docker containers start, browse to http:// < computer running Blockscout > :4000 to view the user interface.
You can also use the API (opens new window)
# GraphQL
Blockscout's API includes GraphQL (opens new window) support under /graphiql
.
For example, this query looks at addresses.
query {
addresses(hashes:[
"0xcB69A90Aa5311e0e9141a66212489bAfb48b9340",
"0xC2dfA7205088179A8644b9fDCecD6d9bED854Cfe"])
2
3
4
GraphQL queries start with a top level entity (or entities). In this case, our top level query (opens new window) is for multiple addresses.
Note that you can only query on fields that are indexed.
For example, here we query on the addresses.
However, we couldn't query on contractCode
or fetchedCoinBalance
.
{
hash
contractCode
fetchedCoinBalance
2
3
4
The fields above are fetched from the address table.
transactions(first:5) {
We can also fetch the transactions that include the address (either as source or destination). The API does not let us fetch an unlimited number of transactions, so here we ask for the first 5.
edges {
node {
2
Because this is a graph (opens new window), the entities that connect two types, for example addresses and transactions, are called edges
.
At the other end of each edge there is a transaction, which is a separate node
.
hash
fromAddressHash
toAddressHash
input
}
2
3
4
5
These are the fields we read for each transaction.
}
}
}
}
2
3
4
Finally, close all the brackets.