0

We are building a NFT marketplace using the 0xv4 NFT contracts. We successfully completed integrations for onchain order processing, but are having a difficulty with offchain order processing. We deployed our own instance of the ERC721OrdersFeature.sol at https://ropsten.etherscan.io/address/0x90A675840686A6e92DB656CEef474E770b7be76A

Specifically, we are unable to validate signatures via validateERC721OrderSignature(order, signature) function on the ERC721OrdersFeature.sol contract.

Here is example code we are using to generate the signature:

const { ERC721Order, NFTOrder, SignatureType } = require("@0x/protocol-utils");
const order = new ERC721Order({
        chainId: 3,
        verifyingContract: '0x0000000000000000000000000000000000000000',
        direction : 1,
        maker : "0x1F4dE329818D2800cc32162D352DeD932DD34438",
        taker : "0xe5d687AAb8769c272547474C59A84EFa83e339ac",
        expiry : 2222222222,
        nonce : 44789,
        erc20Token : "0xE436313CAaaD56D6934AC0A94998a8468602548b",
        erc20TokenAmount : 1,
        fees : [],
        erc721Token : "0x94d1CE401E13289BB3215aDec4545e8Dc01f7ca7",
        erc721TokenId : 2,
        erc721TokenProperties : []
});
const EIP712_DOMAIN_PARAMETERS = [
    { name: 'name', type: 'string' },
    { name: 'version', type: 'string' },
    { name: 'chainId', type: 'uint256' },
    { name: 'verifyingContract', type: 'address' },
];
 
const FEE_ABI = [
    { type: 'address', name: 'recipient' },
    { type: 'uint256', name: 'amount' },
    { type: 'bytes', name: 'feeData' },
];
 
const PROPERTY_ABI = [
    { type: 'address', name: 'propertyValidator' },
    { type: 'bytes', name: 'propertyData' },
];
 
const STRUCT_ABI = [
    { type: 'uint8', name: 'direction' },
    { type: 'address', name: 'maker' },
    { type: 'address', name: 'taker' },
    { type: 'uint256', name: 'expiry' },
    { type: 'uint256', name: 'nonce' },
    { type: 'address', name: 'erc20Token' },
    { type: 'uint256', name: 'erc20TokenAmount' },
    { type: 'Fee[]', name: 'fees' },
    { type: 'address', name: 'erc721Token' },
    { type: 'uint256', name: 'erc721TokenId' },
    { type: 'Property[]', name: 'erc721TokenProperties' },
];
 
const { domain, message } = order.getEIP712TypedData();
 
const types = {
    EIP721Domain : EIP712_DOMAIN_PARAMETERS,
    'ERC721Order': STRUCT_ABI,
    'Fee': FEE_ABI,
    'Property': PROPERTY_ABI,
};
 
var msgParams = JSON.stringify({types, domain, primaryType: 'ERC721Order', message});
var from = "0x1F4dE329818D2800cc32162D352DeD932DD34438";
var params = [from, msgParams];
var method = 'eth_signTypedData_v4';
 
var signature;
await web3.currentProvider.sendAsync(
    {
        method,
        params,
        from,
    },
    function async (err, result) {
                if (err) return console.dir(err);
                if (result.error) {
                  alert(result.error.message);
                }
                if (result.error) return console.error('ERROR', result);
                console.log('TYPED SIGNED:' + JSON.stringify(result));
                const { v, r, s } = ethers.utils.splitSignature(result.result);
                signature = { v, r, s, signatureType: 2 };
        }
);

The signature is successfully validated via the provided node modules, but not via the function on the smart contract.

We appreciate any assistance in this matter. Thank you!

1 Answer 1

0

EIP721Domain : EIP712_DOMAIN_PARAMETERS should be EIP712Domain : EIP712_DOMAIN_PARAMETERS Let me know if it works!

1
  • That fixed our troubles. We thank you profusely. Jun 9, 2022 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.