Skip to main content



Params is a module-wide configuration structure that stores system parameters and defines overall functioning of the peggy module. Detailed specification for each parameter can be found in the Parameters section.

  • Params: Paramsspace("peggy") -> legacy_amino(params)

Validator Info

Ethereum Address by Validator

Stores each Validator's corresponding delegate Ethereum address indexed by the validator's account address.

[]byte{0x1} + []byte(validatorAddr)Ethereum addresscommon.AddressProtobuf encoded

Validator by Ethereum Address

Stores each Validator's account address indexed by Ethereum address.

[]byte{0xfb} + []byte(ethAddress)Validator addresssdk.ValAddressProtobuf encoded


Stored in two possible ways, first with a height and second without (unsafe). Unsafe is used for testing and export and import of state. Currently Peggy.sol is hardcoded to only accept batches with a single token type and only pay rewards in that same token type.

// OutgoingTxBatch represents a batch of transactions going from Peggy to ETH
type OutgoingTxBatch struct {
BatchNonce uint64
BatchTimeout uint64
Transactions []*OutgoingTransferTx
TokenContract string
Block uint64
[]byte{0xa} + []byte(tokenContract) + nonce (big endian encoded)A batch of outgoing transactionstypes.OutgoingTxBatchProtobuf encoded


This is the validator set of the bridge.

Stored in two possible ways, first with a height and second without (unsafe). Unsafe is used for testing and export and import of state.

// Valset is the Ethereum Bridge Multsig Set, each peggy validator also
// maintains an ETH key to sign messages, these are used to check signatures on
// ETH because of the significant gas savings
type Valset struct {
Nonce uint64
Members []*BridgeValidator
Height uint64
RewardAmount sdkmath.Int
// the reward token in it's Ethereum hex address representation
RewardToken string

[]byte{0x2} + nonce (big endian encoded)Validator settypes.ValsetProtobuf encoded


The latest validator set slash nonce. This is used to track which validator set needs to be slashed and which already has been.

[]byte{0xf5}Nonceuint64encoded via big endian


The latest validator set nonce, this value is updated on every write.

[]byte{0xf6}Nonceuint64encoded via big endian

Valset Confirmation

When a validator signs over a validator set this is considered a valSetConfirmation, these are saved via the current nonce and the orchestrator address.

// MsgValsetConfirm
// this is the message sent by the validators when they wish to submit their
// signatures over the validator set at a given block height. A validator must
// first call MsgSetEthAddress to set their Ethereum address to be used for
// signing. Then someone (anyone) must make a ValsetRequest the request is
// essentially a messaging mechanism to determine which block all validators
// should submit signatures over. Finally validators sign the validator set,
// powers, and Ethereum addresses of the entire validator set at the height of a
// ValsetRequest and submit that signature with this message.
// -------------
type MsgValsetConfirm struct {
Nonce uint64
Orchestrator string
EthAddress string
Signature string
[]byte{0x3} + (nonce + []byte(AccAddress)Validator Confirmationtypes.MsgValsetConfirmProtobuf encoded


When a validator confirms a batch it is added to the confirm batch store. It is stored using the orchestrator, token contract and nonce as the key.

// MsgConfirmBatch
type MsgConfirmBatch struct {
Nonce uint64
TokenContract string
EthSigner string
Orchestrator string
Signature string

[]byte{0xe1} + []byte(tokenContract) + nonce + []byte(AccAddress)Validator Batch Confirmationtypes.MsgConfirmBatchProtobuf encoded


When a validator would like to delegate their voting power to another key. The value is stored using the orchestrator address as the key

[]byte{0xe8} + []byte(AccAddress)Orchestrator address assigned by a validator[]byteProtobuf encoded


A validator has an associated counter chain address.

[]byte{0x1} + []byte(ValAddress)Ethereum address assigned by a validator[]byteProtobuf encoded


Sets an outgoing transactions into the applications transaction pool to be included into a batch.

// OutgoingTransferTx represents an individual send from Peggy to ETH
type OutgoingTransferTx struct {
Id uint64
Sender string
DestAddress string
Erc20Token *ERC20Token
Erc20Fee *ERC20Token
[]byte{0x6} + id (big endian encoded)User created transaction to be included in a batchtypes.OutgoingTransferTxProtobuf encoded



Represents the latest slashed block height. There is always only a singe value stored.

[]byte{0xf7}Latest height a batch slashing occurreduint64Big endian encoded

TokenContract & Denom

A denom that is originally from a counter chain will be from a contract. The token contract and denom are stored in two ways. First, the denom is used as the key and the value is the token contract. Second, the contract is used as the key, the value is the denom the token contract represents.

[]byte{0xf3} + []byte(denom)Token contract address[]bytestored in byte format
[]byte{0xf4} + []byte(tokenContract)Latest height a batch slashing occurred[]bytestored in byte format


The last observed event nonce. This is set when TryAttestation() is called. There is always only a single value held in this store.

[]byte{0xf2}Last observed event nonceuint64Big endian encoded


This is the last observed height on ethereum. There will always only be a single value stored in this store.

[]byte{0xf9}Last observed Ethereum Heightuint64Protobuf encoded


// Attestation is an aggregate of `claims` that eventually becomes `observed` by
// all orchestrators
// EventNonce a nonce provided by the peggy contract that is unique per event fired
// These event nonces must be relayed in order. This is a correctness issue,
// if relaying out of order transaction replay attacks become possible
// Observed indicates that >67% of validators have attested to the event,
// and that the event should be executed by the peggy state machine
type Attestation struct {
Observed bool
Votes []string
Height uint64
Claim *types.Any
[]byte{0x5} + evenNonce (big endian encoded) + []byte(claimHash)Attestation of occurred events/claimstypes.AttestationProtobuf encoded