What you’ll need
- A basic understanding of the Mirror product’s more basic ETL use case.
- A basic understanding of SQL, though we use the syntax and functionality of Flink v1.17.
- A destination sink to write your data to.
Preface
When it comes to identifying native transfers on a chain it’s important to highlight that there are two types of accounts that can interact with transactions:- Externally Owned Accounts (EOA): controlled by an actual user.
- Contract Accounts: controlled by code.
Pipeline YAML
There is one transform in this configuration and we’ll explain how it works. If you copy and use this configuration file, make sure to update:- Your
secret_name
(v2:secretName
). If you already created a secret, you can find it via the CLI commandgoldsky secret list
. - The schema and table you want the data written to, by default it writes to
public.eth_transfers
.
native-transfers.yaml
Native Transfers Transform
We’ll start at the top.Traces context columns
Transaction Type
trace_address
column to identify whether this an initial EOA transaction or an internal one. This is also optional to include.
Token Value
IMPORTANT: The CASE statement above with the 1e9 division is ONLY for Ethereum mainnet. If you’re working with other chains, replace the entire CASE statement with:This correction is needed because values before block 17999551 on Ethereum were incorrectly multiplied by 1e9 in the dataset. Other chain datasets do not have this issue.
Some columns are surrounded by backticks, this is because they are reserved words in Flink SQL. Common columns that need backticks are: data, output, value, and a full list can be found here.
Filter
call_type <> 'delegatecall'
: delegatecall is a type of function call where the called contract’s code is executed with the state of the calling contract, including storage and balance. In some cases, it can mistakenly carry over the value transfer of the original calling contract which would compromise our data quality due to value transfer duplications. As a result, we can safely leave them out of our resulting dataset as delegatecalls can never send value with them.value > 0
: we want to make sure we track transactions with actual native value.status = 1
: the Raw Traces dataset can contain traces which got reverted. With this filter, we make sure to consider only successful transactions.
Deploying the pipeline
To deploy this pipeline and start sinking ERC-20 transfer data into your database simply execute:goldsky pipeline create <pipeline_name> --definition-path <yaml_file>
Can’t find what you’re looking for? Reach out to us at support@goldsky.com for help.