As an example use-case, we will build a price oracle for the $Atom token in order to store ATOM/USD price on-chain.

# Setup and Config

We will be using Starport (opens new window) to setup our blockchian.

Follow the Starport docs to get your app up and running.

# Import the Oracle Module

Import the Oracle module into app/app.go. You can take a look at https://github.com/relevant-community/oracle/blob/main/app/app.go and search for instances of oraclekeeper and oracletypes.

Note: make sure to add the OracleModule to the paramsKeeper.

Copy // initParamsKeeper init params keeper and its subspaces func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) //... paramsKeeper.Subspace(oracletypes.ModuleName) return paramsKeeper }

# Configure Oracle Parameters

We need to set some parameters for our oracle type. In config.yaml add:

Copy genesis: app_state: oracle: params: claim_params: AtomClaim: # This is our oracle 'type' vote_period: 3 # Voting round duration in blocks claim_type: 'AtomClaim' # Oracle type again prevote: true # Require commit-reveal type voting to avoid free-rider problem vote_threshold: '0.5' # Validator power threshold required to reach consensus

Note AtomClaim is the claim type we will need to use when submitting our cliams.

The oracle can process any number of claim types - simply add them to the claim_params map