Commodity Prices
Commodity Price Oracle
Lumia provides real-time commodity price feeds through an on-chain oracle system, allowing developers to access current market prices for various commodities including precious metals, energy products, and agricultural goods.
Overview
The commodity price oracle provides real-time price data for:
Precious Metals (XAU/Gold, XAG/Silver, XPT/Platinum)
Energy (Brent Oil, Natural Gas)
Agricultural (Wheat, Corn, Sugar, Milk, Barley)
Industrial Metals (Copper, Aluminum)
How to Use
Contract Details
Mainnet
Oracle Contract Address:
0x146447574c02deB3B802A1d4c9447CB7648aA56D
Sender Address:
0x1ad5b38c108feca340398538e45c4e3abcce7401
Testnet
Oracle Contract Address:
0x146447574c02deB3B802A1d4c9447CB7648aA56D
Sender Address:
0x682e737dcd1d679cb0dbfd34b137038480d45ead
Integration Example
Here's a simple example showing how to query commodity prices in your smart contracts:
Available Commodity Keys
Each commodity has a unique key for price queries. Here are the available commodities and their corresponding keys:
Precious Metals
Gold (XAU/USD)
Mainnet Key:
0x1A4CF14646A65ED92B0F79291D4B537D4D634DAF4AE7BDEA7F95E16AFC106676
Testnet Key:
0x8A8DF5C5476AD99D933701968710B3E18D16864A1D08F10916F09ED75E638DBB
Data Source: investing.com/currencies/xau-usd
Silver (XAG/USD)
Mainnet Key:
0xBB2F960A195C867A42E2AA5340AF4B3C62E789C0568FBBCE1925417E0FC62024
Testnet Key:
0xF6743B90FD9E84F36C8E4D4D44A1642360BEFEBB48804CA013A613447930D311
Data Source: investing.com/currencies/xag-usd
Energy
Brent Oil
Mainnet Key:
0x08250CF04C3D466C046942A4C0968A955202155F43CADB5699065CC1CD966BA7
Testnet Key:
0x694848F20CA37676DF8E14670A53CD521332673EAFEC2F6735D0D3064891BE82
Data Source: investing.com/commodities/brent-oil
Natural Gas (NG)
Mainnet Key:
0x598B52FA996FB56351A0B86CEFB0D12210D046DA2372044271F3495FC36081C9
Testnet Key:
0x5AADF097C2159913CAA090D92F4947F7423FBC2404F6F6CDE21382E81B499198
Data Source: investing.com/commodities/natural-gas
Industrial Metals
Copper (XCU)
Mainnet Key:
0x3C66B438005B1823E9544AC4BCA1BF1F3F70E40F75EBCD0F6E2DB3E968EF46E5
Testnet Key:
0xEB93D2CB02A06E6CE522A66C58A90300E2A41B1226EED095141AD0B8B759BCF7
Data Source: fxempire.com/commodities/copper
Aluminum (ALU)
Mainnet Key:
0xC746629AF536F44CA9EB4CEC98D18FE161700538200FABD786095A8D4894E0C2
Testnet Key:
0xE5CE8F97E49B8C566DB4B97E61B0D89E6C08ED27D014A26C657D134C0A16199E
Data Source: markets.businessinsider.com/commodities/aluminum-price
Testing the Oracle
You can test the oracle integration using the Neeedle UI:
Mainnet: Neeedle UI Mainnet Link
Testnet: Neeedle UI Testnet Link
To test:
Connect your wallet to the appropriate network (Mainnet or Testnet)
Use the
readAsUint256ByKey()
functionInput the sender address and commodity key
Click "Read" to get the current price
Best Practices
Error Handling: Always implement proper error handling when interacting with the oracle
Gas Optimization: Cache oracle responses when possible instead of querying frequently
Validation: Verify returned prices are within expected ranges before using them
Update Frequency: Consider the update frequency of the price feeds when designing your application
Technical Considerations
Price feeds are updated regularly but may have slight delays
Check and confirm decimal places for each feed
Prices are sourced from reliable market data providers
The oracle contract is non-upgradeable for security
Support
For technical support or questions about the commodity price oracle:
Review the contract on Explorer
Last updated