IOutputReceiver API

The commented source code for the IOutputReceiver API may be found on this page

Implementing

Contracts desiring to implement IOutputReceiver must implement the interface and all of its methods, inherit from OpenZeppelin ERC165, and include the following code to specify that they implement IOutputReceiver in the manner prescribed by EIP-165:

function supportsInterface(bytes4 interfaceId) public view override(ERC165, IERC165) returns (bool) {
    return interfaceId == type(IOutputReceiver).interfaceId
        || super.supportsInterface(interfaceId);
}

Contracts desiring to further implement IOutputReceiverV2 and IOutputReceiverV3 should include the additional lines in their return statement, as each interface is desired.

return interfaceId == type(IOutputReceiver).interfaceId
            || interfaceId == type(IOutputReceiverV2).interfaceId
            || interfaceId == type(IOutputReceiverV3).interfaceId
            || super.supportsInterface(interfaceId);

Methods

ReceiveRevestOuput

function receiveRevestOutput(
        uint fnftId,
        address asset,
        address payable owner,
        uint quantity
    ) external;

Parameters

  • fnftId: the unique FNFT ID that represents the configuration for an FNFT series stored on that ID. Recommended for the storage of FNFT-specific data within the implementing contract. Calls to TokenVault may be used to get the config for the associated FNFT

  • asset: the address representing the ERC-20 asset that was stored within the FNFT and has (if not the zero-address) been transferred to the implementing contract prior to this callback function being called

  • owner: the user who initiated the successful withdrawal of the FNFT associated with this call. Whatever value the associated FNFT represents should be transferred to the user at the conclusion of this callback

  • quantity: how many FNFTs of this type were withdrawn from

Description

The function receiveRevestOutput is the quintessential function that allows output receivers to function as modular systems built on top of the Revest contract stack. Whenever an FNFT is successfully withdrawn from, any value stored within it is transferred to its output receiver, and this function is then called on the aforementioned output receiver to trigger custom value-handling behavior. If all value is stored in the output receiver contract itself and the FNFT functions purely as a placeholder, this method serves to alert the output receiver that the conditions for withdrawal have been successfully met.

GetCustomMetadata

function getCustomMetadata(uint fnftId) external view returns (string memory);

Parameters

  • fnftId: the id associated with the FNFT the metadata is desired for. Typically not utilized.

  • returns: a string pointing to a URL (preferably, an IPFS one) where the metadata file for the Output Receiver in question may be found. May also be a data URL of <base64/json> type.

Description

This method points to where the metadata file for the output receiver resides. It should be hosted somewhere that the URL is unlikely to change in the future, such as IPFS, to avoid breaking the ability for the frontend to properly collect and encode parameters for the Address Lock to properly function. This function is not mandatory, but is typically necessary for a generalizable Output Receiver.

GetValue

function getValue(uint fnftId) external view returns (uint);

Parameters

  • fnftId: The id associated with the FNFT the value of which is desired

  • returns: an integer representing the value stored within the requested FNFT

Description

This method will determine what number is displayed on the front of the FNFT GUI. If the FNFT in question utilizes TokenVault for storage, the solution offered in UniswapDemo is recommended to report accurate value for rebase tokens. Otherwise, this function should return implementation-specific values, such as how many NFTs are stored within the FNFT in the case of NFTLocker.

GetAsset

function getAsset(uint fnftId) external view returns (address);

Parameters

  • fnftId: The id associated with the FNFT the asset of which is requested for display purposes

  • returns: an address representing the value stored within the referenced FNFT

Description

Gets the underlying asset which the FNFT represented by the passed in ID contains. For something where an ERC-20 is stored either within the implementing contract or within a smart-wallet (see Self-Destructing Clone Pattern), return that asset, and the output value of getValue will be properly formatted according to the decimals proscribed by that ERC20. Otherwise, if the value is an ERC-721 or 1155, the symbol() and name() methods present in most implementations will allow the FNFT GUI to accurately list the name and ticker of the underlying assets.

GetOutputDisplayValues

function getOutputDisplayValues(uint fnftId) external view returns (bytes memory);

Parameters

  • fnftId: the id associated with the FNFT whose custom output data is requested for display to the end-user

  • returns: a bytes array that represents whatever data should be decoded by the frontend according to the metadata file specified with getCustomMetadata

Description

This function allows the output receiver to send custom data via the abi.encode(arg1, arg2, etc...) method. Provided that the output receiver Domain-Specific Language supports the data type, a wide variety of dev-dictated modifications may be made to the default Revest interface. The linked video succinctly encapsulates this workflow and should communicate this concept in concert with a thorough reading of the Output Receiver Overview.

Last updated