Discover a secure and
lightweight solution.
Build DeFi apps with seamless cross-chain communication and
rapid fast price feed.
rapid fast price feed.
0.0+
Messages
0.0+
Request Prices
0
Networks
Explore top crypto price like Bitcoin,
Ethereum, and more
Simply and securely buy, sell, and manage hundreds of cryptocurrencies.
Simple to access
accurate prices rapidly.
Easily request prices by interact with xOracle's price feed contracts instantly using 'requestPrices'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 1. send request prices to xOracle contract
function requestPrices() external {
// allowance req fee
IERC20(weth).approve(xOracle, type(uint256).max);
bytes memory payload = ""; // no payload
uint256 expired = 0; // no expiration
uint256 maxGasPrice = 10e9; // 10 gwei
uint256 callbackMaxGasLimit = 5000000; // 5M
IXOracle(xOracle).requestPrices(payload, expired, maxGasPrice, callbackMaxGasLimit);
}
// 2. callback from xOracle fulfill prices
function xOracleCall(uint256 _reqId, bool _priceUpdate, bytes memory _payload) external onlyXOracle {
// get all latest prices
(, uint256 btcPrice, , ) = IXOracle(xOracle).getLastPrice(0); // BTC
(, uint256 ethPrice, , ) = IXOracle(xOracle).getLastPrice(1); // ETH
(, uint256 bnbPrice, , ) = IXOracle(xOracle).getLastPrice(2); // BNB
(, uint256 usdtPrice, , ) = IXOracle(xOracle).getLastPrice(3); // USDT
...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
// # source chain
// send message to endpoint contract address on the destination chain
function send(address _token, uint256 _amount, uint64 _dstChainId, uint256 _dstTokenIndex, address _receiver) external payable {
// get fee
uint256 fee = IXOracleMessage(xOracleMessage).getFee(_dstChainId);
require(msg.value >= fee, "insufficient fee");
...
// send message
bytes memory payload = abi.encode(uid, srcTokenIndex, _dstTokenIndex, _amount, chainId, _dstChainId, msg.sender, _receiver);
IXOracleMessage(xOracleMessage).sendMessage{ value: msg.value }(payload, endpointAddress, _dstChainId);
}
Send message across chains.
Effortlessly teransmit messages across chains with seamless integration.
Experience the fluidity of cross-chain communication facilitated by xOracle.
Explore DeFi apps using xOracle
Visit the powerful DeFi applications empowered by the trusted data provided by xOracle.