forked from joshstevens19/rindexer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrindexer.yaml
More file actions
79 lines (79 loc) · 2.5 KB
/
Copy pathrindexer.yaml
File metadata and controls
79 lines (79 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: ERC1155BalancesExample
description: Test ERC1155 token balance tracking using iterate for TransferBatch
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: https://mainnet.gateway.tenderly.co
storage:
postgres:
enabled: true
drop_each_run: true
contracts:
- name: OpenSea
details:
- network: ethereum
# OpenSea's Seaport - has ERC1155 TransferBatch events
address: "0x00000000006c3852cbEf3e08E8dF289169EdE581"
start_block: 18600000
end_block: 18600500
abi: ./abis/ERC1155.json
tables:
- name: balances
columns:
- name: holder
- name: token_id
- name: balance
type: uint256
default: "0"
events:
# Handle batch transfers with iterate
- event: TransferBatch
iterate:
- "$ids as token_id"
- "$values as amount"
operations:
# Credit recipient for each token
- type: upsert
where:
holder: $to
token_id: $token_id
if: "$to != 0x0000000000000000000000000000000000000000"
set:
- column: balance
action: add
value: $amount
# Debit sender for each token
- type: upsert
where:
holder: $from
token_id: $token_id
if: "$from != 0x0000000000000000000000000000000000000000"
set:
- column: balance
action: subtract
value: $amount
# Handle single transfers normally (no iterate needed)
- event: TransferSingle
operations:
# Credit recipient
- type: upsert
where:
holder: $to
token_id: $id
if: "$to != 0x0000000000000000000000000000000000000000"
set:
- column: balance
action: add
value: $value
# Debit sender
- type: upsert
where:
holder: $from
token_id: $id
if: "$from != 0x0000000000000000000000000000000000000000"
set:
- column: balance
action: subtract
value: $value