In this section, we will learn how to pack multiple values into a single message.
We can use abi.encode() to encode multiple values into a single byte array:
We can see here in how we use the function abi.encode() to turn multiple values (someString, someNumber & someAddress) of various types (string, uint & address) into a single value of the type bytes called message. This bytearray can then be sent to the destination chain using the Teleporter.
The receiving contract can then decode the byte array back into its original values:
Here we are using abi.decode() to unpack the three values (someString, someNumber & someAddress) from the parameter message of the type bytes. As you can see in we do need to provide the message as well as the types of the values encoded in the message in the same order as parameters to abi.decode().