|
1 |
| -# Terra Wormhole Contracts |
| 1 | +# Pyth Cosmwasm |
2 | 2 |
|
3 |
| -The Wormhole Terra integration is developed and maintained by Everstake / @ysavchenko. |
| 3 | +This crate includes the actual contract and exposes utilities to interact with the contract on the CosmWasm ecosystem. |
| 4 | +It also includes an [example contract](../examples/cw-contract/) demonstrating how to read price feeds from on-chain CosmWasm applications. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +Add this crate to the dependencies section of your CosmWasm contract's `Cargo.toml` file: |
| 9 | + |
| 10 | +``` |
| 11 | +[dependencies] |
| 12 | +pyth-cosmwasm = { git="https://github.com/pyth-network/pyth-crosschain", rev="5d0acc1", features=["library"] } |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Simply import the structs exposed by the crate and use them while interacting with the pyth contract. For example: |
| 18 | + |
| 19 | +```rust |
| 20 | +// to query Pyth contract |
| 21 | +use pyth_cosmwasm::msg::{ |
| 22 | + PriceFeedResponse, |
| 23 | +}; |
| 24 | + |
| 25 | +... { |
| 26 | + let price_feed_response: PriceFeedResponse = |
| 27 | + deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart { |
| 28 | + contract_addr: state.pyth_contract_addr.into_string(), |
| 29 | + msg: to_binary(&PythQueryMsg::PriceFeed { |
| 30 | + id: state.price_feed_id, |
| 31 | + })?, |
| 32 | + }))?; |
| 33 | + |
| 34 | + let price_feed = price_feed_response.price_feed; |
| 35 | +} |
| 36 | +.... |
| 37 | +``` |
| 38 | + |
| 39 | +## Off-Chain Queries |
| 40 | + |
| 41 | +You can use the provided schemas in the `./pyth/schema` directory to directly query the CosmWasm contract from off-chain applications. |
| 42 | +A typical query requires to pass the price feed id as a hex string. it will look like: |
| 43 | + |
| 44 | +``` |
| 45 | +{ |
| 46 | + "price_feed": { |
| 47 | + "id": "f9c0172ba10dfa4d19088d94f5bf61d3b54d5bd7483a322a982e1373ee8ea31b" |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +## Contracts and Price Feeds |
| 53 | + |
| 54 | +Pyth is currently available on the following cosmwasm chains: |
| 55 | + |
| 56 | +### Testnet |
| 57 | + |
| 58 | +| Network | Contract address | |
| 59 | +| --------- | -------------------------------------------- | |
| 60 | +| Injective | `inj1z60tg0tekdzcasenhuuwq3htjcd5slmgf7gpez` | |
| 61 | + |
| 62 | +Available price feeds on these networks can be find below: |
| 63 | + |
| 64 | +### Price Feeds |
| 65 | + |
| 66 | +| Network | Available Price Feeds | |
| 67 | +| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ | |
| 68 | +| Injective Testnet | [https://pyth.network/developers/price-feed-ids#injective-testnet](https://pyth.network/developers/price-feed-ids#injective-testnet) | |
0 commit comments