|
|
преди 2 години | |
|---|---|---|
| .. | ||
| schema | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | преди 2 години |
| src | 6daeb88244 [cosmwasm] Update example contract (#593) | преди 2 години |
| Cargo.lock | 6daeb88244 [cosmwasm] Update example contract (#593) | преди 2 години |
| Cargo.toml | d95c9247a2 [cosmwasm] Release setup (#594) | преди 2 години |
| Developing.md | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | преди 2 години |
| README.md | 084acdb57e [refactor] Convert hyphen to underscore in the directory tree (#524) | преди 2 години |
This repository contains an example contract that demonstrates how to query Pyth on-chain contract. The example contract has two functions:
instantiate sets the Pyth contract address and price feed id that the contract uses.
This function is intended to be called once when the contract is deployed.
See the price-feed-ids for the list of possible price feed ids.query queries the Pyth contract
This example contract is running on Injective testnet at inj1cc9effer9ttdfrkfghfj7y3ph48c36a9y8d7cv.
This contract has been instantiated to return the price of Crypto.INJ/USD.
You can query the contract using the schema at schema/example-cw-contract.json.
Some example queries:
{
"fetch_price": {}
}
If the query is successful, the output should look like:
{
current_price: { price: "8704350000", conf: "3150000", expo: -8, publish_time: "1674224555332" },
ema_price: { price: "8665158600", conf: "2965370", expo: -8, publish_time: "1674224555332" }
}
If the price feed is currently not available you will see:
rpc error: code = Unknown desc = Generic error: Current price is not available: contract query failed
If you would like to deploy a changed version of this contract, the process consists of two steps:
See the Developing instructions for how to build the WASM for the contract.
The instructions in that document will build a file called example_cw_contract.wasm under the artifacts/ directory.