ERC721WrapperUpgradeable
Inherits: Initializable, ERC721Upgradeable, IERC721Receiver
Extension of the ERC-721 token contract to support token wrapping. Users can deposit and withdraw an "underlying token" and receive a "wrapped token" with a matching tokenId. This is useful in conjunction with other modules. For example, combining this wrapping mechanism with {ERC721Votes} will allow the wrapping of an existing "basic" ERC-721 into a governance token.
State Variables
ERC721WrapperStorageLocation
bytes32 private constant ERC721WrapperStorageLocation =
0xa27ade666fc2e768f0cfbad659dfd6a7039cae52f9274d2ab808f70dce364400;
Functions
_getERC721WrapperStorage
function _getERC721WrapperStorage() private pure returns (ERC721WrapperStorage storage $);
__ERC721Wrapper_init
function __ERC721Wrapper_init(IERC721 underlyingToken) internal onlyInitializing;
__ERC721Wrapper_init_unchained
function __ERC721Wrapper_init_unchained(IERC721 underlyingToken) internal onlyInitializing;
depositFor
Allow a user to deposit underlying tokens and mint the corresponding tokenIds.
function depositFor(address account, uint256[] memory tokenIds) public virtual returns (bool);
withdrawTo
Allow a user to burn wrapped tokens and withdraw the corresponding tokenIds of the underlying tokens.
function withdrawTo(address account, uint256[] memory tokenIds) public virtual returns (bool);
onERC721Received
Overrides IERC721Receiver-onERC721Received to allow minting on direct ERC-721 transfers to this contract. In case there's data attached, it validates that the operator is this contract, so only trusted data is accepted from {depositFor}. WARNING: Doesn't work with unsafe transfers (eg. {IERC721-transferFrom}). Use {ERC721Wrapper-_recover} for recovering in that scenario.
function onERC721Received(address, address from, uint256 tokenId, bytes memory) public virtual returns (bytes4);
_recover
Mint a wrapped token to cover any underlyingToken that would have been transferred by mistake. Internal function that can be exposed with access control if desired.
function _recover(address account, uint256 tokenId) internal virtual returns (uint256);
underlying
Returns the underlying token.
function underlying() public view virtual returns (IERC721);
Errors
ERC721UnsupportedToken
The received ERC-721 token couldn't be wrapped.
error ERC721UnsupportedToken(address token);
Structs
ERC721WrapperStorage
Note: storage-location: erc7201:openzeppelin.storage.ERC721Wrapper
struct ERC721WrapperStorage {
IERC721 _underlying;
}