How to initiate user message signing

Hello,

Consider this code:

window.ethereum
    .request({
      method: 'eth_signTypedData_v4',
      params: [window.ethereum.selectedAddress, JSON.stringify('asdf')],
    })
    .then((result) => {
      console.log(result);
    })
    .catch((error) => {
      console.log(error);
    });

Yields an error like:

MetaMask - RPC Error: Cannot use 'in' operator to search for 'undefined' in undefined

What am I doing wrong?

1 Like