Subscribe to amazoon7.eth
Subscribe to amazoon7.eth
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers
introduction
Oracles like RedStone bridge real-world data to smart contracts. In this tutorial, we’ll explore three core methods to integrate RedStone into your projects: Simple API, Advanced SDK, and Direct Smart Contract Integration.
---
### 1. Using RedStone’s Simple API
Best for: Decentralized apps (dApps) needing quick data access.
Benefits: No complex coding, cost-effective, beginner-friendly.
Steps:
1. Get an API Key:
Visit the [RedStone Developer Portal](https://app.redstone.finance/) to generate your API key.
2. Fetch Data:
Use the endpoint below to retrieve token price data (e.g., ETH):
curl "https://api.redstone.finance/prices?symbol=ETH&provider=redstone"
3. Process the Response:
The JSON response includes price, update timestamp, and data source:
{
"ETH": {
"value": 2500,
"timestamp": 1678901234,
"source": "binance"
}
}
---
2. Using RedStone’s Advanced SDK
Best for: Projects requiring customized data or on-chain processing.
Benefits: High flexibility, multi-purpose data support, seamless framework integration.
Steps:
1. Install the SDK:
Use npm or yarn:
npm install @redstone-finance/sdk
2. Fetch Data in Code:
JavaScript example to retrieve ETH price:
import { requestData } from "@redstone-finance/sdk";
const data = await requestData({
dataServiceId: "redstone-main-demo",
uniqueSigners: \["0x..."\], // Validator addresses
dataFeeds: \["ETH"\]
});
console.log(data.ETH); // Output: { value: 2500, ... }
3. Inject Data into Smart Contracts:
Use the updateDataFeeds method in your contract to push data on-chain.
---
3. Direct Integration with Smart Contracts
Best for: Advanced DeFi protocols prioritizing security and full control.
Benefits: Full decentralization, reduced reliance on external infrastructure.
Steps:
1. Import RedStone’s Interface:
Use the redstone-oracles library in your smart contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@redstone-finance/contracts/contracts/PriceFeed.sol";
contract MyContract {
PriceFeed public priceFeed;
constructor(address \_priceFeedAddress) {
priceFeed = PriceFeed(\_priceFeedAddress);
}
function getETHPrice() public view returns (uint256) {
return priceFeed.getLatestPrice("ETH");
}
}
2. Deploy the Contract:
Input RedStone’s PriceFeed contract address for your target chain (e.g., Ethereum or Polygon).
3. Validate Data:
Data is automatically verified by RedStone’s decentralized validators.
---
Summary: Which Method to Choose?
- API: Ideal for MVPs or small-scale projects.
- SDK: Perfect for dApps with custom requirements.
- Smart Contracts: Optimal for security-sensitive protocols like lending or staking.
---
Additional Resources:
- [RedStone Technical Docs](https://docs.redstone.finance/)
- [Integration Video Tutorial](https://youtube.com/redstone)
With RedStone, bring real-world data on-chain cheaper and faster! 🚀
Additional Resources:

introduction
Oracles like RedStone bridge real-world data to smart contracts. In this tutorial, we’ll explore three core methods to integrate RedStone into your projects: Simple API, Advanced SDK, and Direct Smart Contract Integration.
---
### 1. Using RedStone’s Simple API
Best for: Decentralized apps (dApps) needing quick data access.
Benefits: No complex coding, cost-effective, beginner-friendly.
Steps:
1. Get an API Key:
Visit the [RedStone Developer Portal](https://app.redstone.finance/) to generate your API key.
2. Fetch Data:
Use the endpoint below to retrieve token price data (e.g., ETH):
curl "https://api.redstone.finance/prices?symbol=ETH&provider=redstone"
3. Process the Response:
The JSON response includes price, update timestamp, and data source:
{
"ETH": {
"value": 2500,
"timestamp": 1678901234,
"source": "binance"
}
}
---
2. Using RedStone’s Advanced SDK
Best for: Projects requiring customized data or on-chain processing.
Benefits: High flexibility, multi-purpose data support, seamless framework integration.
Steps:
1. Install the SDK:
Use npm or yarn:
npm install @redstone-finance/sdk
2. Fetch Data in Code:
JavaScript example to retrieve ETH price:
import { requestData } from "@redstone-finance/sdk";
const data = await requestData({
dataServiceId: "redstone-main-demo",
uniqueSigners: \["0x..."\], // Validator addresses
dataFeeds: \["ETH"\]
});
console.log(data.ETH); // Output: { value: 2500, ... }
3. Inject Data into Smart Contracts:
Use the updateDataFeeds method in your contract to push data on-chain.
---
3. Direct Integration with Smart Contracts
Best for: Advanced DeFi protocols prioritizing security and full control.
Benefits: Full decentralization, reduced reliance on external infrastructure.
Steps:
1. Import RedStone’s Interface:
Use the redstone-oracles library in your smart contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@redstone-finance/contracts/contracts/PriceFeed.sol";
contract MyContract {
PriceFeed public priceFeed;
constructor(address \_priceFeedAddress) {
priceFeed = PriceFeed(\_priceFeedAddress);
}
function getETHPrice() public view returns (uint256) {
return priceFeed.getLatestPrice("ETH");
}
}
2. Deploy the Contract:
Input RedStone’s PriceFeed contract address for your target chain (e.g., Ethereum or Polygon).
3. Validate Data:
Data is automatically verified by RedStone’s decentralized validators.
---
Summary: Which Method to Choose?
- API: Ideal for MVPs or small-scale projects.
- SDK: Perfect for dApps with custom requirements.
- Smart Contracts: Optimal for security-sensitive protocols like lending or staking.
---
Additional Resources:
- [RedStone Technical Docs](https://docs.redstone.finance/)
- [Integration Video Tutorial](https://youtube.com/redstone)
With RedStone, bring real-world data on-chain cheaper and faster! 🚀
Additional Resources:

No activity yet