For Smart Contract Developers

Smart contract developers often need to analyze their data. Assuming you are a developer from EigenLayer, and your community is requesting a comprehensive dashboard on how each wallet addresses stake with EigenLayer, here are the steps you can follow to accomplish this using the Hemera Protocol.

Create your data model

To store the result, we can design a simple data model

class DailyWalletTokenStaking(BaseModel):
    date = Column(Date)
    wallet_address = Column(String)
    token_address = Column(String)
    balance = Column(Numeric)

Understand your smart contract data

You must include all the transactions/logs/traces, which may change your output data. For your use case, you need to identify all the staking balance changes.

If you understand your contract well, you should figure out that this transaction will trigger a user-staking balance change.

Method: depositIntoStrategy: https://etherscan.io/tx/0x7269c2cf90779d82b3b53f6c997cabd25243cb60f6f136e8ce5a1e6d510d478e

Design trigger event

To summarize, whenever you see a transaction that interacts with this specific address (EigenLayer: Strategy Manager) and calls this specific function (depositIntoStrategy) from your smart contract, you should update the user staking balance.

You can define this customized trigger within the indexer using this code.

# 0xe7a050aa is refering to the depositIntoStrategy
0x858646372CC42E1A627fcE94aa7A7033e7CF075A
(EigenLayer: Strategy Manager)
if transaction.to_address == "" and transaction.method_id == "0xe7a050aa":
    # call update_daily_wallet_token_staking
    update_daily_wallet_token_staking(transaction, logs, traces)

The trigger can be a method in transactions, topics from logs, or even an action from the trace.

Write customize code

Now we can add our code and update our data model when an event is triggered. The event will pass transaction data/logs/traces to you.

You can write your customized code and update the data model you design.

def update_daily_wallet_token_staking(
    transaction: Transaction, logs: Log[], traces: Trace[]
    ):
    # Get balance change from logs
    
    # Update model
    
    

Last updated