MetaMask Message Signature: TypeError: Cannot read property 'toArray' of null

I’m trying to sign a message using eth_signTypedData_v4,


but I kept getting the error message above. Please has anyone experienced this issue before or is something wrong with the data I’m passing to eth_signTypedData_v4.

:1234: Code to reproduce

createProposal = async ({ title, description, category }, { loading, web3, ethereum, user } = this.state) => {
    if(loading) return;
    try {
      const _data = JSON.stringify({
        types: {
            EIP712Domain: [
              { name: "name", type: "string" },
              { name: "version", type: "string" },
              { name: "chainId", type: "uint256" },
              { name: "verifyingContract", type: "address" },
              { name: "salt", type: "bytes32" },
          ],
            Dao: [{ name: "wallet", type: "address" }]
        },
        domain: {
            name: "SignTypedData v4 Test",
            version: "1",
            chainId: parseInt(web3.version.network, 10),
            verifyingContract: "0x1C56346CD2A2Bf3202F771f50d3D14a367B48070", // doesn't exist yet
            salt: "0xf2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a558" // doesn't exist yet
        },
        primaryType: "Dao",
        message: {
            title,
            description,
            category
        }
    });
      const _signature = web3.currentProvider.sendAsync({
        method: "eth_signTypedData_v4",
        params: [user, _data],
        from: user
      }, (err, res) => {
        if(err) return console.log("err", err);
        console.log(res);
      });
      return _signature;
    } catch (error) {
      console.log(error);
      return error;
    }
  }

The description of the Dao type only contains a field wallet, yet your message contains title, description, category. Type and message should match.

1 Like