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:

  1. The first step involves creating a new project and setting up the necessary development environment.

  2. 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.

  3. Execute the script and see the latest update

Step 1: Environment Setup

Initialize a new yarn project and add dependencies.

$ yarn init cdt-price-watcher -y && yarn add --dev viem typescript ts-node

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.

import { createPublicClient, createWalletClient, http, getContract } from 'viem'
import { mainnet } from 'viem/chains'

// Create client instance to mainnet
const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),

// Declare Request params
const dataSpotterAddress = "0xffffffffffffffffffffffffffffffffffffffff"
const SynthSID = "";
const dataSpotterAbi = [
] as const

// Create DataSpotter contract instance
const dataSpotter = getContract({
  address: dataSpotterAddress,
  abi: dataSpotterAbi,
  client: {
    public: publicClient,

// Await and print the latest CDT price
const lpPrice = await dataSpotter.getLpPriceBySid(SynthSID)
console.log(`latest lp price of ${SynthSID} = ${lpPrice}`)

Last updated