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 — Bepolia 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_TESTNET_RPC(e.g.https://bepolia.rpc.berachain.com). - Deploy consumer contract
- Fetch price and update on-chain
- Read price:
cast call <CONTRACT> --rpc-url $BERACHAIN_TESTNET_RPC "getPrice()"
StalePrice — re-run the update; InsufficientFee — increase --value (e.g. 0.0005ether).
Key files
| Purpose | Path |
|---|---|
| Consumer contract | src/ConsumerContract.sol |