# Implement the Claim interface of the Oracle Module
create a new file x/<your_module>/types/atomUsd.go
Copy
package types
import(
fmt "fmt"
sdk "github.com/cosmos/cosmos-sdk/types""github.com/tendermint/tendermint/crypto/tmhash"
tmbytes "github.com/tendermint/tendermint/libs/bytes")// AtomUsd creates a new AtomUsd claimfuncNewAtomUsd(blockHeight int64, price string)*AtomUsd {
decPrice, err := sdk.NewDecFromStr(price)if err !=nil{returnnil}return&AtomUsd{
Price: decPrice,
BlockHeight: blockHeight,}}// Claim methods that implement the abstract Claim interface of the oracle module// ValidateBasic performs basic validation of the claimfunc(c *AtomUsd)ValidateBasic()error{if c.BlockHeight <1{return fmt.Errorf("invalid claim height: %d", c.BlockHeight)}returnnil}// Type return type of oracle Claimfunc(c *AtomUsd)Type()string{return AtomClaim
}// Hash returns the hash of an Claim Content.func(c *AtomUsd)Hash() tmbytes.HexBytes {
bz, err := c.Marshal()if err !=nil{panic(err)}return tmhash.Sum(bz)}// GetRoundID returns the block height for when the data was used.func(c *AtomUsd)GetRoundID()uint64{returnuint64(c.BlockHeight)}// GetConcensusKey returns a key the oracle will use of vote consensus// for deterministic results it should be the same as the hash of the content// for nondeterministic content it should be a constantfunc(c *AtomUsd)GetConcensusKey()string{return""}
Note: because validators may return different prices within a given round, GetConsensusKey should return some constant value. This is because we will have a custom method to come to a 'consensus' about the results of the round.