Chainlink API Guide

The industry-standard oracle network

Connect to Real-World Data

Chainlink provides secure oracle services for DeFi. Get price feeds, VRF, and external adapters.

Products

Price Feeds

Get real-time asset prices for DeFi. Used by Aave, Compound, and major protocols.

VRF

Verifiable Random Function. Generate provably fair random numbers for NFTs and gaming.

Keeper Network

Automate smart contract functions. Trigger liquidations, rebalancing, and more.

Read Price Data

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract PriceConsumerV3 {
    AggregatorV3Interface internal priceFeed;

    constructor() {
        priceFeed = AggregatorV3Interface(0x...); // ETH/USD address
    }

    function getLatestPrice() public view returns (int) {
        (,int price,,,) = priceFeed.latestRoundData();
        return price;
    }
}

Use Cases

DeFi Lending

Use price feeds for collateral valuation and liquidations.

NFT Gaming

VRF for random NFT traits and game rewards.

Insurance

Trigger policy payouts based on real-world events.