Skip to main content

Stork Oracle

Stork is a decentralized oracle network that provides aggregated price feeds from a distributed set of data providers. It is designed to support decentralized applications such as DEXes, prediction markets, and gaming platforms. You can learn more about Stork here.

The Stork Oracle Chromia extension integrates Stork price feeds into Chromia blockchains by verifying and injecting the latest price updates at the beginning of each block.

Blockchain configuration

When you lease your container, ensure you select the Stork Oracle Chromia extension. To start using the extension, configure your blockchain to listen for asset updates and include the necessary Stork extensions. Below is a sample configuration:

chromia.yml
blockchains:
<my_blockchain_name>:
module: <module_name>
config:
gtx:
modules:
- "net.postchain.stork.StorkOracleGTXModule"
sync_ext:
- "net.postchain.stork.StorkOracleSynchronizationInfrastructureExtension"
stork:
assets:
- "BTCUSD"
- "ETHUSD"
- "..."

Assets: Specify the list of assets (e.g., BTCUSD, ETHUSD) that you want the extension to monitor for updates. You can find the complete list of assets at this link.

The extension should already be aware of all publisher public keys. However, if it should ever be necessary, you can override the Stork public key and publisher public keys as follows:

chromia.yml
blockchains:
<my_blockchain_name>:
module: <module_name>
config:
stork:
stork_pubkey: x"0a803F9b1CCe32e2773e0d2e98b37E0775cA5d44"
publisher_pubkeys: # List ALL publisher keys here if you want to override
- x"5c946686b0302be54d85394015a9f9fa0952984e"
- "..."

Rell Integration

Integrate the Stork Oracle Extension library into your Rell project by adding it to your configuration:

chromia.yml
libs:
stork:
registry: https://gitlab.com/chromaway/core/stork-oracle-chromia-extension
path: rell/src/stork
tagOrBranch: 1.0.1
rid: x"EBB409F91EBC5EB3816570C9FDB5A170180249CF7F74EEDFC09C428E288F4114"
insecure: false

To process price updates in your application, extend the on_stork_oracle_prices_update hook:

@extend(on_stork_oracle_prices_update) function handle_price_update(stork_oracle_prices) {
/ Add your custom logic here
}

The stork_oracle_prices struct provides detailed information about price updates:

struct stork_oracle_prices {
asset: text;
stork_price;
publisher_prices: list<publisher_price>;
}

struct stork_price {
price: big_integer;
signature;
timestamp_nanos: integer;
merkle_root: byte_array;
type: text;
version: text;
checksum: byte_array;
}

struct publisher_price {
price: big_integer;
signature;
timestamp_seconds: integer;
}

struct signature {
signer: byte_array;
r: byte_array;
s: byte_array;
v: byte_array;
}

The extension automatically verifies the signatures, so you don't need to include that logic in your Rell code.

Prices are represented as big_integer with 18 decimal places. Use the following utility function to convert prices to decimal format:

function convert_price_to_decimal(price: big_integer): decimal

You can find the source code and further details about the Stork Oracle Chromia extension in the official repository.