Comment on page
🔵
How to Integration APassOracle
- Address: 0xffd89fe22fd620d2cba0b3aaccdde6f5ad63ce7a7b18d13c0dc61e21521affff
You can easily access AOracle real-time data through API.

The maximum delay between on-chain data and API data is 5 seconds
You should add a dependency in your project move.toml
[package]
name = "YourProject"
version = "0.0.1"
upgrade_policy = "compatible"
[dependencies]
AptosFramework = { local = "../../aptos-core-main/aptos-move/framework/aptos-framework" }
AptosStdlib = { local = "../../aptos-core-main/aptos-move/framework/aptos-stdlib" }
AptosToken = { local = "../../aptos-core-main/aptos-move/framework/aptos-token" }
// Add this line
AOracle = { git = "https://github.com/AptosPassport/aoracle-contract.git", rev = "main" }
Then add the module reference in the move code, and use AOracle like follow:
module YourProject::SomeModule {
use std::error;
use std::vector;
use std::signer;
// Use AOracle moudule
use AOracle::oracle;
/**
* @notice Get latest recorded price from oracle
*/
fun getPriceFromOracle(): (u64, u64) {
let (roundId, price, _, timestamp, _) =
oracle::latestRoundDataByName(string::utf8("APTUSDT"));
(roundId, price)
}
}
Last modified 7mo ago