targetcontract within itself, hence the term meta. The outer transaction helps facilitate the first on-chain call which is sent by a relayer. The call is forwarded to the
targetcontract using an intermediate smart contract (Gelato Relay), which in turn forwards the call using the inner transaction to deliver the relayed message.
targetcontract address, and the calldata payload used to target a specific function.
targetsmart contract function, the function needs to authenticate that the message was created by the correct party, and forwarded through the correct relayer. Otherwise, your
targetfunction is open to exploits. EIP-2771 uses clever data encoding to allow for a new
_msgSenderto be relayed from off-chain, and a
trustedForwarderaddress to be set. Together, these two parameters protect against any foul play and allow for information to be sent from off-chain on-chain!
msg.senderloses its informational value. Whereas usually, the
msg.senderwould be the user initiating the transaction, with off-chain relaying, we lose this valuable information.
msg.senderwill be the relayer, but whitelisting this address is both permissioned and still not enough to stop some one else using the same relayer from calling your function. This can be especially worrisome when low-level calls are involved.
targetsmart contract can now authenticate a function call using this address.
targetcontract for extra security. This trusted forwarder contract verifies the signature relayed from off-chain via the executor to verify the relay request.
targetsmart contract on a which a function is called by the calldata.
fromaddress i.e. the off-chain address into the calldata by appending it at the end:
fromaddress by decoding the data in the same way, making sure this message has been passed through the
targetcontract function can be sure that the correct entity signed and requested this payload to be relayed, only via a trusted forwarder - in our case, Gelato Relay.
_isGelatoRelay(address _forwarder): a function which returns true if the address matches Gelato Relay's address.
_getFeeCollector(): a function to retrieve the fee collector address.
_getFee(): a function to retrieve the fee that Gelato will charge.
_getFeeToken(): a function to retrieve the address of the token used for fee payment.
_transferRelayFee(): a function which transfers the fee amount to Gelato, with no cap.
_transferRelayFeeCapped(uint256 _maxFee): a function which transfers the fee amount to Gelato which a set cap from the argument
maxFeein wei. This helps limit fees on function calls in case of gas volatility or just for general budgeting.