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.

{
  "networkId": "base-mainnet",
  "protocolName": "public",
  "contractName": "AERO",
  "eventName": "Transfer",
  "sig": "Transfer(address,address,uint256)",
  "fourBytes": "0xddf252ad",
  "contractAddress": "0x940181a94a35a4569e4529a3cdfb74e38fd98631",
  "blockTime": "2024-06-25T06:53:35Z",
  "blockHeight": 16254534,
  "txHash": "0x3d4e1443d71ed1fabe05832b769fbdd317e498bd6532aabd6dae02997c53a4d5",
  "txIndex": 47,
  "eventIndex": 242,
  "data": "{\"value\": 122139709492256489, \"from\": \"0xfb5d7540faf21a3a0db0da41fd2fe923f93c74ea\", \"to\": \"0x2223f9fe624f69da4d8256a7bcc9104fba7f8f75\"}"
}

Smart Contract Event Fields

FieldDescription
networkIdBlockchain network for the smart contract, e.g., base-mainnet.
protocolNameName of the blockchain protocol, e.g., public.
contractNameName of the smart contract, e.g., AERO.
eventNameType of event, e.g., token transfer.
sigThe event signature for the smart contract event.
fourBytesThe first 4 bytes (8 hex characters) of the Keccak-256 hash of the event signature (also known as the event topic).
contractAddressAddress of the smart contract.
blockTimeTimestamp when the block was mined.
blockHeightNumber of the block containing the transaction.
txHashHash of the transaction that triggered the event.
txIndexPosition of the transaction within the block.
eventIndexPosition of the event log within the transaction.
dataThe 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.

{
  "abi": "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_initialMessage\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]",
  "contract_address": "0x000000007172DE22E5E9d8bAF0EdaC6f37da006",
  "contract_name": "Test Smart Contract",
  "network_id": "base-mainnet",
  "smart_contract_id": "6d38535b-0c2a-48b8-b1b0-a6f49c39fe70",
  "type": "custom"
}

Smart Contract Fields

FieldDescription
abiABI of the smart contract
network_idBlockchain network for the smart contract, e.g., base-mainnet.
contract_nameName of the smart contract, e.g., AERO.
contract_addressAddress of the smart contract.
typeType of the smart contract. “Custom” indicates the contract is uploaded by yourself
smart_contract_idID of the smart contract