You need to implement a single contract that executes an offchain-signed EIP-712 order to exchange ERC721 (tokenId) for an ERC20 payment.
Requirements:
fillatomically executes two transfers: IERC721 and ERC20 transfers in opposite directions.- EIP-712
order.makersignature with EOA and ERC-1271 support cancel(nonce)makes the nonce unusable- Use foundry
struct Order {
address maker;
address taker;
address nft;
uint256 tokenId;
address paymentToken;
uint256 amount;
uint256 minReceive;
uint256 nonce;
uint256 deadline;
}
struct Permit {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
function fill(
Order calldata order,
bytes calldata makerSignature,
Permit calldata permitData,
address recipient
) external;
function cancel(uint256 nonce) external;
event OrderFilled(
bytes32 orderHash,
address maker,
address taker,
address nft,
uint256 tokenId,
address paymentToken,
uint256 netReceived,
address recipient
);
event OrderCanceled(address maker, uint256 nonce);