πŸ§‘Execution Paths & Inner Payloads.

Execution Paths And InnerPayloads

While working with axelar for cross chain communication. We highlighted a pattern tha we believe should be in the developer docs and a lot of cross chan applications would use. which is Execution Paths and Inner Payloads. To describe this we'll be bringing a segment of mrKrabz contract to explain.

When you have different function updating different things you'll need to put this into play.

  1. All Functions Should Have An Execution Path ID

 // execution path handlers
    uint256 public topUpWalletPath = 1;
    uint256 public buyTicketPath = 2;
    uint256 public newRoundPath = 3;
    uint256 public setRandomWinnersPath = 4;
    uint256 public claimWinningsPath = 5;
    uint256 public withdrawFromWalletPath = 6;

  1. Always Encode The Execution Path ID As The First Param In Your Payload

This will give you the ability to decide what your inner payload would be in your _execute function.

Your innerPayload is basically all your other encoded parameters into one payload.

In this instance in our inner payload we encoded the params we need such as our FILECOIN_CHAIN_ID, _nativeAsset, _user .

We then passed the innerPayload into the main payload along with its execution path.

  1. Separate All Execution Paths In _execute function

This allows you to be more flexible with your paramterers and have diffrenet outcomes for different function calls.

Last updated