Smart Contract Events
Smart Contract Events
You can upload and manage any smart contract of interest through the CDP Portal, CDP SDK or the CDP API. It simplifies the retrieval of event data from specific smart contracts, making it easier to integrate blockchain data into your application.
Here are some quickstart examples for using the Smart Contract Events API.
Configuration Options
You can retrieve smart contract events using either:
- CDP API: Offers direct access to event data via RESTful APIs.
- CDP SDK: Enables developers to interact programmatically with smart contracts through a specialized SDK.
Both methods support various blockchain networks and allow seamless integration into your infrastructure.
Sample Smart Contract Event
The following is an example of a parsed smart contract event. This is typically returned when you query for events using the indexer.
Smart Contract Event Fields
Field | Description |
---|---|
networkId | Blockchain network for the smart contract, e.g., base-mainnet . |
protocolName | Name of the blockchain protocol, e.g., public . |
contractName | Name of the smart contract, e.g., AERO . |
eventName | Type of event, e.g., token transfer. |
sig | The event signature for the smart contract event. |
fourBytes | The first 4 bytes (8 hex characters) of the Keccak-256 hash of the event signature (also known as the event topic). |
contractAddress | Address of the smart contract. |
blockTime | Timestamp when the block was mined. |
blockHeight | Number of the block containing the transaction. |
txHash | Hash of the transaction that triggered the event. |
txIndex | Position of the transaction within the block. |
eventIndex | Position of the event log within the transaction. |
data | The event-specific data emitted during the event in JSON format, e.g., - from : Address of the sender in the token transfer. - to : Address of the recipient. - value : Amount of tokens transferred. |
Sample Smart Contract
The following is an example of a smart contract object.
Smart Contract Fields
Field | Description |
---|---|
abi | ABI of the smart contract |
network_id | Blockchain network for the smart contract, e.g., base-mainnet . |
contract_name | Name of the smart contract, e.g., AERO . |
contract_address | Address of the smart contract. |
type | Type of the smart contract. “Custom” indicates the contract is uploaded by yourself |
smart_contract_id | ID of the smart contract |