Skip to content

Commit

Permalink
rename to erc20-balances-transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 27, 2025
1 parent c72866b commit 2993bee
Show file tree
Hide file tree
Showing 35 changed files with 69 additions and 28 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"erc20-balances",
"erc20-balances-transfers",
"clickhouse",
"subgraphs",
]
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ERC-20 Balances
# ERC-20 Substreams

> Substreams for tracking ERC-20 token balances & transfers for EVM blockchains.
>
Expand All @@ -10,3 +10,9 @@ Includes the following:
- [x] Apache Parquet
- [x] Clickhouse SQL
- [ ] Subgraphs (SpS)

## Modules included

- [x] ERC-20 Balances & Transfers
- [ ] ERC-20 Contract Metadata
- [ ] ERC-20 Supply
4 changes: 2 additions & 2 deletions clickhouse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "erc20-balances-clickhouse"
name = "erc20-clickhouse"
description = { workspace = true }
edition = { workspace = true }
version = { workspace = true }
Expand All @@ -10,4 +10,4 @@ crate-type = ["cdylib"]
[dependencies]
substreams = { workspace = true }
substreams-database-change = "2.0"
erc20-balances = { path = "../erc20-balances" }
erc20-balances-transfers = { path = "../erc20-balances-transfers" }
2 changes: 1 addition & 1 deletion clickhouse/src/db_out.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use erc20_balances::pb::erc20::types::v1::Events;
use erc20_balances_transfers::pb::erc20::types::v1::Events;
use substreams::errors::Error;
use substreams_database_change::pb::database::DatabaseChanges;

Expand Down
10 changes: 5 additions & 5 deletions clickhouse/substreams.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
specVersion: v0.1.0
package:
name: erc20_balances_clickhouse
name: erc20_clickhouse
version: v1.5.0
url: https://github.com/pinax-network/substreams-erc20-balances
url: https://github.com/pinax-network/substreams-erc20

imports:
database_changes: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v2.0.0/substreams-database-change-v2.0.0.spkg
sql: https://github.com/streamingfast/substreams-sink-sql/releases/download/protodefs-v1.0.7/substreams-sink-sql-protodefs-v1.0.7.spkg
database_change: https://github.com/streamingfast/substreams-sink-database-changes/releases/download/v2.0.0/substreams-database-change-v2.0.0.spkg
erc20_balances: https://spkg.io/pinax-network/erc20-balances-v1.5.0.spkg
erc20_balances: ./erc20-balances/erc20-balances-transfers-v1.5.0.spkg

binaries:
default:
type: wasm/rust-v1
file: target/wasm32-unknown-unknown/release/erc20_balances_clickhouse.wasm
file: target/wasm32-unknown-unknown/release/erc20_clickhouse.wasm

modules:
- name: db_out
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "erc20-balances"
name = "erc20-balances-transfers"
description = { workspace = true }
edition = { workspace = true }
version = { workspace = true }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Substreams ERC20 Balance Changes
# Substreams: `ERC20 Balances & Transfers`
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

The goal of this Substreams project is to extract all ERC20 transfers from Ethereum events for the full chain.

The `map_balance_changes` module will output messages of type [erc20.types.v1.BalanceChange](./proto/v1/erc20.proto#L15) defined by:
The `map_balance_changes` module will output messages of type [erc20.types.v1.BalanceChange](./proto/v1/erc20.proto#L15) defined by:

```proto
message BalanceChange {
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
specVersion: v0.1.0
package:
name: erc20_balances
name: erc20_balances_transfers
version: v1.5.0
url: https://github.com/pinax-network/substreams-erc20-balances

binaries:
default:
type: wasm/rust-v1
file: target/wasm32-unknown-unknown/release/erc20_balance.wasm
file: ../target/wasm32-unknown-unknown/release/erc20_balances_transfers.wasm

protobuf:
files:
- erc20.proto
importPaths:
- ./proto/v1
- ../proto/v1
excludePaths:
- sf/substreams
- google
Expand Down
File renamed without changes.
21 changes: 17 additions & 4 deletions duckdb/README.md → parquet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,37 @@

## Quickstart

**Install [`substreams-sink-files`](https://github.com/streamingfast/substreams-sink-files)**
### Install [`substreams-sink-files`](https://github.com/streamingfast/substreams-sink-files)

```bash
brew install streamingfast/tap/substreams-sink-files
```

**Download parquet files from Substreams**
### Install [Duckdb](https://duckdb.org/#quickinstall)

```bash
curl https://install.duckdb.org | sh
```

### Download parquet files from Substreams
```bash
substreams-sink-files run eth.substreams.pinax.network:443 \
https://spkg.io/pinax-network/erc20-balances-v1.5.0.spkg map_events \
"./out" 21525891:21526891 \
--encoder parquet --file-block-count 1
```

**Query the parquet files with DuckDB**
Folder structure:

- `./out`
- `./balance_changes`
- `./transfers`

### Query the parquet files with DuckDB

> Select the top sending addresses for DAI by total transferred value.
```sql
-- Select the top sending addresses for DAI by total transferred value.
SELECT
"from",
count() as total_transfers,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions subgraphs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "erc20-balances-subgraphs"
name = "erc20-subgraph"
description = { workspace = true }
edition = { workspace = true }
version = { workspace = true }
Expand All @@ -10,4 +10,4 @@ crate-type = ["cdylib"]
[dependencies]
substreams = { workspace = true }
substreams-entity-change = "2.0"
erc20-balances = { path = "../erc20-balances" }
erc20-balances-transfers = { path = "../erc20-balances-transfers" }
2 changes: 1 addition & 1 deletion subgraphs/src/graph_out.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use erc20_balances::pb::erc20::types::v1::Events;
use erc20_balances_transfers::pb::erc20::types::v1::Events;
use substreams::errors::Error;
use substreams_entity_change::pb::entity::EntityChanges;

Expand Down
22 changes: 22 additions & 0 deletions subgraphs/substreams.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
specVersion: v0.1.0
package:
name: erc20_subgraph
version: v1.5.0
url: https://github.com/pinax-network/substreams-erc20

imports:
entity_changes: https://github.com/streamingfast/substreams-sink-entity-changes/releases/download/v2.0.0/substreams-entity-change-v2.0.0.spkg
erc20_balances: ./erc20-balances/erc20-balances-transfers-v1.5.0.spkg

binaries:
default:
type: wasm/rust-v1
file: target/wasm32-unknown-unknown/release/erc20_subgraph.wasm

modules:
- name: graph_out
kind: map
inputs:
- map: erc20_balances:map_events
output:
type: proto:sf.substreams.sink.entity.v1.EntityChanges

0 comments on commit 2993bee

Please sign in to comment.