Standard Relayer

Standard Relayer

The Standard Relayer provides a mechanism for a contract on one chain to send a message to a contract on a different chain without the developer dealing with any off chain deployments.

Tutorials

  • Hello Wormhole A tutorial that covers message passing across EVM environments

  • Hello Token A tutorial that covers token transfer across EVM environments

On Chain

On chain, a smart contract interacts with the IWormholeRelayer to send and receive messages.

Sending a message

To send a message to a contract on another EVM chain, we can call the sendPayloadToEvm method, provided by the IWormholeRelayer interface.

The sendPayloadToEvm method is marked payable so we can pay for our transaction to be submitted.

The value to attach to the invocation is determined by calling the quoteEVMDeliveryPrice, which provides an estimate of the cost of gas on the target chain.

This method should be called prior to sending a message and the value returned for nativePriceQuote should be attached to the call to send the payload in order to cover the cost of the transaction on the target chain.

In total, sending a message across EVM chains can be as simple as:

Receiving a message

To receive a message using the Standard Relayer feature, the target contract must implement the IWormholeReceiver interface.

The logic inside the function body may be whatever business logic is required to take action on the specific payload.

Other Considerations

Some implementation details should be considered during development to ensure safety and improve UX.

  • Receiving a message from relayer

    • Check for expected emitter

    • call parseAndVerify on any additionalVAAs

  • Replay protection

  • Message Ordering

    • no guarantees on order of messages delivered

  • Fowarding/Call Chaining

  • Refunding overpayment of gasLimit

  • Refunding overpayment of value sent

Off Chain

If taking advantage of Automatic Relaying, no off chain logic need be implemented.

While no off chain programs are required, a developer may want to track the progress of messages in flight. To track the progress of messages in flight, use the worm CLI tool's status subcommand.

See the CLI tool docs for installation and usage.

See Also

Reference documentation for EVM chains is available here

Last updated

Was this helpful?