Documentation ¶
Overview ¶
Package chain reads an EVM chain and returns ERC20, ERC721 and ERC1155 transfer event logs. The data returned is []*TransferEvent, and it is cleansed and enhanced with TransferType to distinguish the token types.
- No graph-related logic is applied here, this is pure event log handling.
- For performance reasons, no additional chain reads are allowed here. It must only be a single log query hitting the chain.
Index ¶
Constants ¶
View Source
const ERC1155_BATCH string = "ERC1155_BATCH"
View Source
const ERC1155_SINGLE string = "ERC1155_SINGLE"
View Source
const ERC20 string = "ERC20"
View Source
const ERC721 string = "ERC721"
Variables ¶
This section is empty.
Functions ¶
func DecodeDataForErc1155Batch ¶
DecodeDataForErc1155Batch decodes the log.Data field from a ERC1155 "batch transfer" event log and returns empty slices if any troubles. []ids and []values are guaranteed to have same number of entries, which could be zero.
Types ¶
type EvmClient ¶
type EvmClient struct { Name string ChainId string LatestBlockNumber uint64 Url string Client *ethclient.Client }
func CreateEvmClient ¶
CreateEvmClient gets an EVM client and name. The name comes from reading embedded file copied from this JSON https://github.com/DefiLlama/chainlist/blob/main/constants/chainIds.json
type TransferEvent ¶
type TransferEvent struct { // Block number BlockNumber uint64 // Block timestamp from chain (enrichment) BlockTimestamp time.Time // Transaction timestamp estimated as a proportion through whole block time, based transaction index inside block (enrichment) TransactionTimestampEstimate time.Time // Index at which first seen in dataset, equivalent of TransactionTimestampEstimate TransactionTimestampEstimateIndex uint // Transaction hash TxHash common.Hash // Transaction index in the block TxIndex uint // Log transfer event is ERC20, ERC721, ERC1155 TransferType string // Log index (can be many logs for one transaction) LogIndex uint // Transfer event log address from LogAddressFrom common.Address // Transfer event log address to LogAddressTo common.Address // Transfer event log address from, time first seen in dataset (enrichment) LogAddressFromFirstSeen time.Time // Transfer event log address to, time first seen in dataset (enrichment) LogAddressToFirstSeen time.Time // Transfer event log address from, index at which first seen in dataset (enrichment) LogAddressFromFirstSeenIndex uint // Transfer event log address to, index at which first seen in dataset (enrichment) LogAddressToFirstSeenIndex uint // Transfer event log, the value of tokens transferred, filled for ERC20, ERC1155, else 0 LogTokenValue big.Int // Transfer event log, the NFT id transferred (natively uint256 on Ethereum), filled for ERC721, ERC1155, else empty LogNftId string // Transfer event log, for ERC1155 this holds the operator (the address of an account/contract that is approved to make the transfer), else 0x LogOperator common.Address // The address that emitted the transfer event log LogEmitterAddress common.Address }
func (*TransferEvent) Print ¶
func (event *TransferEvent) Print(title string)
Click to show internal directories.
Click to hide internal directories.