Get CDT Price on EVM
To get the latest CDT price from EVM-based blockchains, you should use the DataSpotter API.
The CDT Price Stream protocol employs a DataSpotter contract to oversee and refresh CDT prices on EVM-compatible blockchains. This method is distinct from other oracle systems that often utilize individual contracts for each asset. Combining price updates and storage in a single contract simplifies the process of accessing the most recent price data for CDT tokens.
This manual is for developers who want to incorporate CDT price information into their backend projects on networks compatible with the Ethereum Virtual Machine (EVM).
Steps Overview:
The first step involves creating a new project and setting up the necessary development environment.
Next, you'll write a TypeScript script that leverages the `viem` library to establish a connection to the DataSpotter contract on the ethereum chain. This script demonstrates how to request the latest CDT price.
Execute the script and see the latest update
Step 1: Environment Setup
Initialize a new yarn project and add dependencies.
Step 2: CDT Price fetcher script
This simple typescript script below uses `viem` to connect to the DataSpotter contract on `mainnet` chain and prints the latest price for `SynthSID` CDT. “SID” - or Synth ID - is essentially a unique identifier for synthetic tokens within a blockchain ecosystem, specifically designed to track and manage LP tokens. It ensures accurate identification and integration of LP tokens.
Last updated