Search
K

Infrastructure Integration

The page is our key strategic infrastructure including partners and the tools we contribute to.

Canoe Infrastructure Integration

More details can be seen in infra blog
Background
Chainlink is a decentralized oracle service currently used by Canoe to provide external data. For the price information of the financial contract on the chain, we can provide stable and accurate price by introducing the ChainLink predictor. Chainlink enables smart contracts on any blockchain to leverage extensive off-chain resources, such as tamper-proof price data, verifiable randomness, external APIs, and much more.
Use Canoe Chainlink module
For convenience, we introduced Canoe ChainLink and used Chainlink’s official Proxy to get prices and so on.
Step1, Solidity version > 0.8.0
pragma solidity ^0.8.0;
Step2, get the proxy from ChainLink data feeds.
Step3, Use Canoe ChainLink github to customize the data demand.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/MetadexContract/CanoeChainLink/blob/main/contracts/CanoeChainLink.sol";
contract CustomizedCase {
CanoeChainLink public canoeChainLink;
/**
* @param _aggregatorAddress This contract requires the default query price address
*/
constructor(address _aggregatorAddress){
canoeChainLink = new CanoeChainLink(_aggregatorAddress);
}
function getDefaultLatestPrice() public view returns (int256 price_){
/*
* Query the aggregator address customized by the contract
* Passing in an empty address is the default aggregator address
* Passing in 0 for the latest price
*/
price_ = canoeChainLink.getLatestPrice(address(0), 0);
}
}
Step4, Use Canoe Chainlink to get the specific demand.
In canoe case, Canoe introduce the price feed on Polygon network.
Polygon Mainnet address: "0xD72e24B934dc614F76BAE3CE43F8498148f82826"
Polygon Testnet address: "0xD72e24B934dc614F76BAE3CE43F8498148f82826"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "https://github.com/MetadexContract/CanoeChainLink/blob/main/contracts/interfaces/ICanoeChainLink.sol";
contract DefaultCase {
ICanoeChainLink public canoeChainLink;
/**
* @param _canoeChainLink Existing address (default view is ETH/USD)
*/
constructor(){
canoeChainLink = ICanoeChainLink();
}
function getDefaultLatestPrice(address _aggregate) public view returns (int256 price_){
/*
* Query aggregate address
* Passing in an empty address is the default aggregator address
* Passing in 0 for the latest price
*/
price_ = canoeChainLink.getLatestPrice(_aggregate, 0);
}
}

Binance Connect