Fraction Protocolhelperserc2771Facet

ERC2771RecipientHelperLib

Implements EIP-2771 standard, as defined in https://eips.ethereum.org/EIPS/eip-2771 This library can be included in a Diamond Facet to provide it with _msgSender() and _msgData()

_msgSender

function _msgSender(struct ERC2771RecipientStorage.Layout layout) internal view returns (address ret)

Returns the sender of this call. If the call came through the trusted forwarder, return the original sender, otherwise, return msg.sender.

Should be used in the contract anywhere instead of msg.sender.

Return Values

NameTypeDescription
retaddressThe address of the real sender of this call.

_msgData

function _msgData(struct ERC2771RecipientStorage.Layout layout) internal view returns (bytes ret)

Returns the msg.data of this call. If the call came through the trusted forwarder, then the real sender was appended as the last 20 bytes of the msg.data - so this method will strip those 20 bytes off. Otherwise (if the call was made directly and not through the forwarder), return msg.data.

Should be used in the contract instead of msg.data, where this difference matters.

Return Values

NameTypeDescription
retbytesThe msg.data of this call.

_isTrustedForwarder

function _isTrustedForwarder(struct ERC2771RecipientStorage.Layout layout, address forwarder) internal view returns (bool)

Queries whether a given address corresponds to the trusted forwarder that is being used.

Parameters

NameTypeDescription
layoutstruct ERC2771RecipientStorage.Layout
forwarderaddressthe address to inquire.

Return Values

NameTypeDescription
[0]boolbool true if the given address is the address of the trusted forwarder, false if not.

On this page