{"id":51046646,"url":"https://github.com/diadata-org/dia-oracle-anchor","last_synced_at":"2026-06-22T14:30:51.420Z","repository":{"id":200537929,"uuid":"656118908","full_name":"diadata-org/dia-oracle-anchor","owner":"diadata-org","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-01T16:50:33.000Z","size":491,"stargazers_count":2,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-21T01:00:04.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diadata-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-20T09:40:32.000Z","updated_at":"2024-01-13T16:32:29.000Z","dependencies_parsed_at":"2023-10-21T13:25:14.827Z","dependency_job_id":null,"html_url":"https://github.com/diadata-org/dia-oracle-anchor","commit_stats":null,"previous_names":["diadata-org/dia-oracle-anchor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/diadata-org/dia-oracle-anchor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diadata-org%2Fdia-oracle-anchor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diadata-org%2Fdia-oracle-anchor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diadata-org%2Fdia-oracle-anchor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diadata-org%2Fdia-oracle-anchor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diadata-org","download_url":"https://codeload.github.com/diadata-org/dia-oracle-anchor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diadata-org%2Fdia-oracle-anchor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34653712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-22T14:30:49.648Z","updated_at":"2026-06-22T14:30:51.412Z","avatar_url":"https://github.com/diadata-org.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DIA Oracles on Aleph Zero\nThis repository contains the source code for DIA oracles on Aleph Zero.\n\n## Oracle Types\nDIA offers two types of oracles on Aleph Zero.\n\n### Asset Price Oracle\nDIA token price feeds provide smart contract real-time price information cryptocurrency assets, transparently sourced from 80+ trusted, high-volume DEXs and CEXs.\nThe feeds facilitate the development of DeFi use cases such as money markets, lending/borrowing, synthetic asset issuance, options, derivatives and futures markets, and many more.\nNew assets can also be supported on demand.\n\n#### Supported assets\nThe deployed DIA oracles support the following assets\n\n| Asset | Query String | Methodology | Update Threshold |\n| ----- | ------------ | ----------- | ---------------- |\n| [Bitcoin](https://www.diadata.org/app/price/asset/Bitcoin/0x0000000000000000000000000000000000000000/) | `BTC/USD` | MAIR120 | 0.1% |\n| [Ether](https://www.diadata.org/app/price/asset/Ethereum/0x0000000000000000000000000000000000000000/) | `ETH/USD` | MAIR120 | 0.1% |\n| [USDC](https://www.diadata.org/app/price/asset/Ethereum/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/) | `USDC/USD` | MAIR120 | 0.1% |\n| [USDT](https://www.diadata.org/app/price/asset/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7/) | `USDT/USD` | MAIR120 | 0.1% |\n| [DOT](https://www.diadata.org/app/price/asset/Polkadot/0x0000000000000000000000000000000000000000/) | `DOT/USD` | MAIR120 | 0.1% |\n| [SOL](https://www.diadata.org/app/price/asset/Solana/0x0000000000000000000000000000000000000000/) | `SOL/USD` | MAIR120 | 0.1% |\n| [AVAX](https://www.diadata.org/app/price/asset/Avalanche/0x0000000000000000000000000000000000000000/) | `AVAX/USD` | MAIR120 | 0.1% |\n| [EUR](https://www.diadata.org/app/price/asset/Fiat/978/) | `EUR/USD` | MAIR120 | 0.1% |\n| [BNB](https://www.diadata.org/app/price/asset/BinanceSmartChain/0x0000000000000000000000000000000000000000/) | `BNB/USD` | MAIR120 | 0.1% |\n| [DOGE](https://www.diadata.org/app/price/asset/Dogechain/0x0000000000000000000000000000000000000000/) | `DOGE/USD` | MAIR120 | 0.1% |\n| [MATIC](https://www.diadata.org/app/price/asset/Polygon/0x0000000000000000000000000000000000001010/) | `MATIC/USD` | MAIR120 | 0.1% |\n| [DAI](https://www.diadata.org/app/price/asset/Ethereum/0x6B175474E89094C44Da98b954EedeAC495271d0F/) | `DAI/USD` | MAIR120 | 0.1% |\n| [AZERO](https://www.diadata.org/app/price/asset/AlephZero/0x0000000000000000000000000000000000000000/) | `AZERO/USD` | MAIR120 | 0.1% |\n\nThe MAIR120 methodology is defined [in detail in the DIA documentation](https://docs.diadata.org/products/token-price-feeds/exchangeprices/mair-moving-average-with-interquartile-range-filter).\n\n### Randomness Oracle\nDIA xRandom provides smart contracts with unpredictable random numbers. DIA leverages drand’s distributed randomness beacon, enabling verifiable, unpredictable and unbiased random numbers.\nThe randomness oracle enables the creation of on-chain applications including but not limited to on-chain gaming, lotteries, prediction markets, and NFT launches. \n\nThe randomness oracle is defined [in detail in the DIA documentation](https://docs.diadata.org/documentation/oracle-documentation/randomness-oracle).\n\n### Deployed Oracles\nDeployed oracles can be accessed at these addresses:\n\n| Network | Oracle Name | Address | Metadata JSON |\n| ------- | ----------- | ------- | ------------- |\n| Testnet | Asset Price Oracle | [`5F5z8pZoLgkGapEksFWc2h7ZxH2vdh1A9agnhXvfdCeAfS9b`](https://contracts-ui.substrate.io/contract/5F5z8pZoLgkGapEksFWc2h7ZxH2vdh1A9agnhXvfdCeAfS9b) | [Price Oracle Metadata](example/dia_oracle.json) |\n| Testnet | Randomness Oracle | [`5CSQdMyKCxtoeVsBC8xbufeapux3YDV74eYXcHV4UKUu1NeF`](https://contracts-ui.substrate.io/contract/5CSQdMyKCxtoeVsBC8xbufeapux3YDV74eYXcHV4UKUu1NeF) | [Randomness Oracle Metadata](example-randomness-oracle/dia_randomness_oracle.json) |\n| Mainnet | Asset Price Oracle | [`5F7wPCMXX65RmL8oiuAFNKu2ydhvgcissDZ3NWZ5X85n2WPG`](https://contracts-ui.substrate.io/contract/5F7wPCMXX65RmL8oiuAFNKu2ydhvgcissDZ3NWZ5X85n2WPG) | [Price Oracle Metadata](example/dia_oracle.json) |\n| Mainnet | Randomness Oracle | [`5HSkrQwqJtmdWL99ocRf1nMwJF9k54uHcQCU5CCctA3zf3q7`](https://contracts-ui.substrate.io/contract/5HSkrQwqJtmdWL99ocRf1nMwJF9k54uHcQCU5CCctA3zf3q7) | [Randomness Oracle Metadata](example-randomness-oracle/dia_randomness_oracle.json) |\n\n## Asset price oracle\nTo facilitate development, the DIA oracles are deployed on Aleph Zero mainnet and testnet.\nAny developer can interact with these oracles without any authentication.\n\n### Oracle contract\nThe smart contract is a key/value store and contains two values per asset, the timestamp of the last update and the value of the asset price.\nThe asset price is stored with 18 decimals by default.\n\nTo interact with this contract via the aleph zero UI, you can import the metadata of the deployed contract in the Contracts UI by subscan:\n\n- Go to https://contracts-ui.substrate.io/contract\n- Choose `aleph zero` or `aleph zero testnet` on top left\n- Choose `Add new contract`\n- Choose `Use Onchain Contract`\n- Enter the contract address\n- Import the metadata json file\n\n#### Compiling the smart contract\nAlternatively to using the provided metadata json, you can generate it yourself.\nGenerate the smart contract files for interacting with the contact and import the resulting file into the Aleph Zero UI.\n\n- Install cargo and required dependencies: https://docs.alephzero.org/aleph-zero/build/aleph-zero-smart-contracts-basics/installig-required-tools\n- Run `cargo contract build --release`\n- Go to https://contracts-ui.substrate.io/contract\n- Choose `aleph zero testnet` on top left\n- Choose `Add new contract`\n- Choose `Use Onchain Contract`\n- Enter `5FmmcSEPiT4sZniwBMs6G89128GTTfPtaWK3jEJPJ9Z77v7U`\n- Import the built file ./target/ink/dia_oracle/dia_oracle.contract\n\n### Interacting with the oracle in your dApp\nThe `example` directory contains an example for how the oracle can be called by a dApp.\nThis piece of code shows how an asset can be retrieved using the `getLatestPrice()` function.\n\n```\n        #[ink(message)]\n        pub fn get(\u0026self, key: String) -\u003e Option\u003c(u64, u128)\u003e {\n            self.oracle.get_latest_price(key)\n        }\n```\nThe key usually is the string symbol of an asset pair, for example, \"BTC/USD\" for the price of Bitcoin.\nThe return value contains two values per asset, the timestamp of the last update and the value of the asset price.\nThe asset price is stored with 18 decimals by default.\n\n## Randomness oracle\nThe randomness oracle is available on Aleph Zero mainnet and testnet and can be used to retrieve randomness from [drand.love](https://drand.love).\n\n### Oracle contract\nRandomness is produced in numbered rounds. Each round's randomness can be retirved individually and the latest round can be queried from the contract directly.\nTo interact with this contract via the aleph zero UI, you can import the deployed contract above.\n\n### Interacting with the oracle\nThe `example-randomness-oracle` directory contains an example for how the radnomness oracle can be called by a dApp.\nThis piece of code shows how an asset can be retrieved using the `getRandomValueForRound()` function.\nThe latest round (the required input parameter for this call) can be retrieved using the `getLatestRound()` function.\n\n```\n        #[ink(message)]\n        pub fn get(\u0026self, key: u64) -\u003e Option\u003cVec\u003cu8\u003e\u003e {\n            self.oracle.get_random_value_for_round(key)\n        }\n```\nThe key is the integer round number, for example 3353171.\nThe return value contains three values per round, the radnomness value, its signature, and the previous round's signature.\n\nOther functions include the retrieval of the latest round ID and the historical round randomnesses.\n\n## Behind the scenes: Feeder setup\nThe smart contract is fed by a piece of software called the *Feeder* which is available as a docker image.\nUnless you want to re-create the entire setup and operate your own oracle, the following section is not relevant.\n\n### Environment for testing the feeder\nThese variables will be read from helm configs as environment variables\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eName\u003c/td\u003e\n        \u003ctd\u003eDefault Value\u003c/td\u003e\n        \u003ctd\u003eDescription\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eDATABASE_URL\u003c/td\u003e\n        \u003ctd\u003epostgresql://user:password@host:port/dbname\u003c/td\u003e\n        \u003ctd\u003ePostgres database URL (optional, for recording transaction IDs)\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eBLOCKCHAIN_NODE\u003c/td\u003e\n        \u003ctd\u003ehttps://rpc.test.azero.dev\u003c/td\u003e\n        \u003ctd\u003eBlockchain RPC\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003ePRIVATE_KEY\u003c/td\u003e\n        \u003ctd\u003e*insert your private updater key here* \u003c/td\u003e\n        \u003ctd\u003ePK of price updater\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eDEPLOYED_CONTRACT\u003c/td\u003e\n        \u003ctd\u003e5FmmcSEPiT4sZniwBMs6G89128GTTfPtaWK3jEJPJ9Z77v7U\u003c/td\u003e\n        \u003ctd\u003ePrice anchor contract deployed\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eASSETS\u003c/td\u003e\n        \u003ctd\u003e\"\n      Bitcoin-0x0000000000000000000000000000000000000000,\n      Ethereum-0x0000000000000000000000000000000000000000,\n      Ethereum-0x84cA8bc7997272c7CfB4D0Cd3D55cd942B3c9419,\n      Ethereum-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,\n      Ethereum-0xdAC17F958D2ee523a2206206994597C13D831ec7,\n      Ethereum-0x6B175474E89094C44Da98b954EedeAC495271d0F,\n      Ethereum-0x853d955aCEf822Db058eb8505911ED77F175b99e,\n      BinanceSmartChain-0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56,\n      Solana-0x0000000000000000000000000000000000000000,\n      Polkadot-0x0000000000000000000000000000000000000000\n      \"\u003c/td\u003e\n        \u003ctd\u003eAssets, whose price is to be stored in the oracle\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eFREQUENCY_SECONDS\u003c/td\u003e\n        \u003ctd\u003e86400\u003c/td\u003e\n        \u003ctd\u003eHow often to feed price onchain\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eSLEEP_SECONDS\u003c/td\u003e\n        \u003ctd\u003e120\u003c/td\u003e\n        \u003ctd\u003eHow often to check DEVIATION_PERMILLE, store new price if need\u003c/td\u003e\n    \u003c/tr\u003e\n        \u003ctr\u003e\n        \u003ctd\u003eORACLE_TYPE\u003c/td\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003eType of oracle for pricing oracle 0, and for randomness oracle 1\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003e Note: these values are just used for testnet. Never share your production private key with anyone.\n\n### How to run to the test with your own feeder\n- Fill your env vars\n- Install docker\n- Run: \n  + `docker build --tag dia-oracle:latest .`\n  + `docker run --rm -p 3000:3000 -d dia-oracle:latest`\n\n### Output\nThe feeder will auto feed price onchain with 18 decimals. If you want to track transaction logs, youcan access them at `http://${host}/api/v1/oracle?page_size=${page_size}\u0026page_index=${page_index}`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiadata-org%2Fdia-oracle-anchor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiadata-org%2Fdia-oracle-anchor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiadata-org%2Fdia-oracle-anchor/lists"}