> ## Documentation Index
> Fetch the complete documentation index at: https://www.diadata.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from Chainlink

> The `DiaAssetSpecificCallingConvention` contract is compatible with `AggregatorV3Interface`, allowing developers to read price data from a DIA oracle contract deployed for each asset by calling `latestRoundData()` and returning the latest available price of that specific asset.

## How the adapter works

Each adapter instance wraps a **single DIA oracle and one asset key** (e.g. `BTC/USD`). When your contract calls `latestRoundData()`, the adapter reads the latest value from DIA's oracle via `getValue()` and maps it onto Chainlink's round format:

* `answer`: the latest DIA price, returned with **18 decimals** by default.
* `updatedAt`: the timestamp of DIA's most recent update.
* `roundId` : set to the current `block.number`.

## Before and after

In practice, only the feed **address** changes.

```solidity theme={"system"}
import {AggregatorV3Interface} from
    "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract MyConsumer {
    AggregatorV3Interface internal priceFeed =
        AggregatorV3Interface(0xChainlinkFeedAddress);

    function getLatestPrice() public view returns (int256) {
        (, int256 answer, , , uint256 updatedAt) = priceFeed.latestRoundData();
        require(updatedAt != 0, "stale price");
        return answer; // 8 decimals
    }
}
```

solidity

```solidity theme={"system"}
import {AggregatorV3Interface} from
    "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract MyConsumer {
    // Same interface — only the address points to the DIA adapter
    AggregatorV3Interface internal priceFeed =
        AggregatorV3Interface(0xDiaAdapterAddress);

    function getLatestPrice() public view returns (int256) {
        (, int256 answer, , , uint256 updatedAt) = priceFeed.latestRoundData();
        require(updatedAt != 0, "stale price");
        return answer; // 8 decimals
    }
}
```

## Migrate in three steps

<Steps>
  <Step title="Get the DIA oracle address and asset key">
    From your network's page in the [chain-specific guides](/docs/guides/chain-guides-overview), copy the DIA oracle contract address and the asset key you need (e.g. `BTC/USD`).
  </Step>

  <Step title="Deploy or obtain the adapter">
    Deploy `DiaAssetSpecificCallingConvention(diaOracleAddress, description, pairKey)`. The repo ships a Hardhat deploy script (`scripts/deployAdapter.ts`). One adapter is deployed per asset.
  </Step>

  <Step title="Swap the address">
    Replace the Chainlink feed address in your contract with the adapter address. No other code changes are required.
  </Step>
</Steps>

## Availability

The adapter works on **any network where a DIA oracle is deployed** (see the [supported chains](/docs/guides/chain-guides-overview)). Because it is asset-specific, a separate adapter is deployed for each price feed you need.

## Reference

<Card title="Chainlink Adapter" icon="github" iconType="solid" horizontal href="https://github.com/diadata-org/AssetSpecificCallingConvention/blob/main/contracts/DiaAssetSpecificCallingConvention.sol" />
