Repository
- Code: github.com/berachain/guides/tree/main/apps/pyth-oracle
- README (raw): raw README
Official documentation
- Pyth Network — oracle overview and on-demand model.
Requirements
- Node
v20.11.0or greater, npm - jq
- Wallet with testnet $BERA — Artio Faucet
- Foundry
Stack
Solidity, Foundry (Forge, Cast), Node.js, Pyth Hermes API (price payloads).Quick start
- Clone and install
- Import wallet (Foundry keystore):
cast wallet import deployer --interactive. SetBERACHAIN_ARTIO_RPC(e.g.https://rpc.ankr.com/berachain_testnet). - Deploy consumer contract
- Fetch price and update on-chain
- Read price:
cast call <CONTRACT> --rpc-url $BERACHAIN_ARTIO_RPC "getPrice()"
StalePrice — re-run the update; InsufficientFee — increase --value (e.g. 0.0005ether).
Key files
| Purpose | Path |
|---|---|
| Consumer contract | src/ConsumerContract.sol |