Package Logo
substreams_base_main
substreams_base_main@v0.1.3
Total Downloads
8
Published
16 hours ago
Publisher
User Avatar noslav

Readme

base_mainnet substreams modules

This package was initialized via substreams init and is being updated with custom modules to support the Base Mainnet blockchain streaming service using substreams.

Nodes available for streaming:

https://docs.substreams.dev/reference-material/chains-and-endpoints

Usage

substreams build
substreams auth
substreams gui       			  # Get streaming!

Optionally, the substreams package can be published to the Substreams Registry

substreams registry login         # Login to substreams.dev
substreams registry publish       # Publish your Substreams to substreams.dev

Data

graph TD;
  map_block_metadata[map: map_block_metadata];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> map_block_metadata;
  map_block_full[map: map_block_full];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> map_block_full;
  map_transactions_all[map: map_transactions_all];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> map_transactions_all;
  map_transactions_filter[map: map_transactions_filter];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> map_transactions_filter;
  map_transaction_traces[map: map_transaction_traces];
  sf.ethereum.type.v2.Block[source: sf.ethereum.type.v2.Block] --> map_transaction_traces;

Running Modules

map_block_metadata

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_block_metadata --start-block 31229579 --stop-block +1


Connected (trace ID be158e2adc379d74d6cb16d11d7ba4cd)
Progress messages received: 0 (0/sec)
Backprocessing history up to requested target block 0:
(hit 'm' to switch mode)

----------- BLOCK #0 (f712aa9241cc24369b143cf6dce85f0902a9731e70d66818a3a5845b296c73dd) age=17279h45m6.540729s ---------------
{
  "@module": "map_block_metadata",
  "@block": 0,
  "@type": "base.mainnet.block_metadata.v1.Metadata",
  "@data": {
    "blockHash": "f712aa9241cc24369b143cf6dce85f0902a9731e70d66818a3a5845b296c73dd",
    "blockTimestamp": "2023-06-15T00:35:47Z",
    "transactionsLen": "1",
    "parentHash": "0000000000000000000000000000000000000000000000000000000000000000"
  }
}
...

map_transactions_all

This module extracts all transactions from a block.

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_transactions_all --start-block 0 --stop-block +10

map_transactions_filter

This module allows you to filter transactions by specifying either to or from value in the parameters.

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_transactions_filter --params='{"to":"0x4200000000000000000000000000000000000015"}' --start-block 31229579 --stop-block +1

map_transaction_traces

This module extracts all transaction traces from a block in their original format.

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_transaction_traces --start-block 31229579 --stop-block +1

This module extracts small bits of block data, and does simple computations over the number of transactions in each block.

map_block_full

This module extracts the entire block, as received by the Substreams module.

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_block_full --start-block 31229579 --stop-block +1

...

----------- BLOCK #99 (c3fa67326430e97a263f8dc0e423d7c6a9f6a244390286b1ba32b80f208b271e) age=17280h9m54.073506s ---------------
{
  "@module": "map_block_full",
  "@block": 99,
  "@type": "sf.ethereum.type.v2.Block",
  "@data": {
    "ver": 4,
    "hash": "0xc3fa67326430e97a263f8dc0e423d7c6a9f6a244390286b1ba32b80f208b271e",
    "number": "99",
    "size": "870",
    "header": {
      "parentHash": "0xa0d20e58a8ec1e43a4eb58c3b2e24d602ff093c4b5bec2815e8abb809dcbf83c",
      "uncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
      "coinbase": "0x4200000000000000000000000000000000000011",
      "stateRoot": "0xe63d6228a77da20a1f19a604decbd5ce8f1739e24fba9aec52f32ac3ad839c8f",
      "transactionsRoot": "0x387c7f8b287f25fbb3f4e955fcdb98020da4c4aa1002bfa82a4d1feb1f083dfc",
      "receiptRoot": "0x3f71ebd8822765e8146170b0f930f55f753dbb867f55e4e605894016cd32f1e2",
      "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "difficulty": {
        "bytes": "0x00"
      },
      "number": "99",
      "gasLimit": "30000000",
      "gasUsed": "46913",
      "timestamp": "2023-06-15T00:39:05Z",
      "mixHash": "0xa2eef66a2a5cf6a3ee6c2da4e6b2cc64ecb77bc057572ef14df0bce5b95b206b",
      "hash": "0xc3fa67326430e97a263f8dc0e423d7c6a9f6a244390286b1ba32b80f208b271e",
      "baseFeePerGas": {
        "bytes": "0x083b038f"
      }
    },
    "transactionTraces": [
      {
        "to": "0x4200000000000000000000000000000000000015",
        "nonce": "98",
        "gasLimit": "1000000",
        "input": "0x015d8eb900000000000000000000000000000000000000000000000000000000010ac03800000000000000000000000000000000000000000000000000000000648a5da3000000000000000000000000000000000000000000000000000000036c55c1de12abd36b698fc225a0a7b895cb61dc803111b48d2cbcc97a45fbeeb9c35e014700000000000000000000000000000000000000000000000000000000000000030000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c900000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0",
        "gasUsed": "46913",
        "type": 126,
        "hash": "0xda7e89e01361bec751e202c385a71b63d33093041d40f4a419a35c79ea28f39f",
        "from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
        "beginOrdinal": "1",
        "endOrdinal": "19",
        "status": "SUCCEEDED",
        "receipt": {
          "cumulativeGasUsed": "46913",
          "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        },
        "calls": [
          {
            "index": 1,
            "callType": "CALL",
            "caller": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
            "address": "0x4200000000000000000000000000000000000015",
            "gasLimit": "977072",
            "gasConsumed": "23985",
            "input": "0x015d8eb900000000000000000000000000000000000000000000000000000000010ac03800000000000000000000000000000000000000000000000000000000648a5da3000000000000000000000000000000000000000000000000000000036c55c1de12abd36b698fc225a0a7b895cb61dc803111b48d2cbcc97a45fbeeb9c35e014700000000000000000000000000000000000000000000000000000000000000030000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c900000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0",
            "executedCode": true,
            "nonceChanges": [
              {
                "address": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
                "oldValue": "98",
                "newValue": "99",
                "ordinal": "3"
              }
            ],
            "gasChanges": [
              {
                "oldValue": "1000000",
                "newValue": "977072",
                "reason": "REASON_INTRINSIC_GAS",
                "ordinal": "2"
              },
              {
                "newValue": "977072",
                "reason": 24,
                "ordinal": "5"
              },
              {
                "oldValue": "974770",
                "newValue": "974722",
                "reason": "REASON_CALL_DATA_COPY",
                "ordinal": "6"
              },
              {
                "oldValue": "974606",
                "newValue": "972106",
                "reason": "REASON_STATE_COLD_ACCESS",
                "ordinal": "7"
              },
              {
                "oldValue": "974706",
                "newValue": "15189",
                "reason": "REASON_DELEGATE_CALL",
                "ordinal": "8"
              },
              {
                "oldValue": "15189",
                "newValue": "953122",
                "reason": "REASON_REFUND_AFTER_EXECUTION",
                "ordinal": "14"
              },
              {
                "oldValue": "953114",
                "newValue": "953111",
                "reason": "REASON_RETURN_DATA_COPY",
                "ordinal": "15"
              },
              {
                "oldValue": "953087",
                "reason": 25,
                "ordinal": "16"
              },
              {
                "oldValue": "953087",
                "reason": 23,
                "ordinal": "18"
              }
            ],
            "beginOrdinal": "4",
            "endOrdinal": "17"
          },
          {
            "index": 2,
            "parentIndex": 1,
            "depth": 1,
            "callType": "DELEGATE",
            "caller": "0x4200000000000000000000000000000000000015",
            "address": "0xc0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d30015",
            "gasLimit": "956917",
            "gasConsumed": "18984",
            "input": "0x015d8eb900000000000000000000000000000000000000000000000000000000010ac03800000000000000000000000000000000000000000000000000000000648a5da3000000000000000000000000000000000000000000000000000000036c55c1de12abd36b698fc225a0a7b895cb61dc803111b48d2cbcc97a45fbeeb9c35e014700000000000000000000000000000000000000000000000000000000000000030000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c900000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0",
            "executedCode": true,
            "storageChanges": [
              {
                "address": "0x4200000000000000000000000000000000000015",
                "key": "0x0000000000000000000000000000000000000000000000000000000000000003",
                "oldValue": "0x0000000000000000000000000000000000000000000000000000000000000002",
                "newValue": "0x0000000000000000000000000000000000000000000000000000000000000003",
                "ordinal": "11"
              }
            ],
            "gasChanges": [
              {
                "newValue": "956917",
                "reason": 24,
                "ordinal": "10"
              },
              {
                "oldValue": "937933",
                "reason": 25,
                "ordinal": "12"
              }
            ],
            "beginOrdinal": "9",
            "endOrdinal": "13"
          }
        ]
      }
    ]
  }
}

Saving Output to Files

To save the output of a substreams module to a file, you can redirect the output to a log file:

> substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_transaction_traces --start-block 90 --stop-block +10 > traces.log

For Mac/Linux users, you can also use the script command to capture all terminal output:

> script -q /dev/null substreams run -e base-mainnet.streamingfast.io:443 substreams.yaml map_transaction_traces --start-block 90 --stop-block +10 | tee traces.log

Documentation

Modules

Maps icon
Maps

map
map_block_metadata

aaa89674e0550e7401c74a77867e1ef71d61d146
map map_block_metadata (
blocksf.ethereum.type.v2.Block
)  -> base.mainnet.block_metadata.v1.Metadata

map_block_metadata allows you to view a basic information about a block

substreams gui substreams-base-main@v0.1.3 map_block_metadata

map
map_block_full

cbfbd3bcc632a790682d1791ff23c02114837d1a

map_block_full allows you to view a complete block, as received by a Substreams module

substreams gui substreams-base-main@v0.1.3 map_block_full

map
map_transactions_all

0295bb728ede98731c708acfddd75b1f44d38800

map_transactions_all returns all transactions from a block without any filtering.

substreams gui substreams-base-main@v0.1.3 map_transactions_all

map
map_transactions_filter

91bcbe875981920e6c8d7e46142558cb56ad1d98
map map_transactions_filter (
paramsstring
)  -> base.mainnet.transaction.v1.Transactions

map_filter_transaction allows you to find a transaction by specifying either to or from value in the parameters. You might need to scope your search to the blocks you know you are going to find that transaction. Check with your preferred block explorer first.

substreams gui substreams-base-main@v0.1.3 map_transactions_filter

map
map_transaction_traces

c8579bca5052bceaf44fb857f00f62aea603e81b

map_transaction_traces returns all transaction traces from a block as-is without any modifications. This uses the existing TransactionTrace proto definition.

substreams gui substreams-base-main@v0.1.3 map_transaction_traces
Protobuf

Protobuf Docs Explorer

sf.ethereum.type.v2
base.mainnet.block_metadata.v1
sf.ethereum.substreams.v1
base.mainnet.transaction.v1
base.mainnet.transaction_traces.v1