✍️Collecting the signature

Once the data is properly generated, the user has to sign it. We'll then have to determine its r,s and v to dispatch the transaction later.

  // sign the message
  let signature
  try {
    signature = signTypedData({
      privateKey: Buffer.from(key, 'hex'),
      data: await messageData.typedData,
      version: SignTypedDataVersion.V4,
    });
    console.log(`Signature successful with hash: ${signature}`);
  }
  catch (signErr) { console.log(signErr, 'signErr') }

  try {
    // validate the message
    let { r, s, v } = await getSignatureParameters(signature);
    formattedSignature = {
      r: r,
      s: s,
      v: v,
    };

  }
  catch (sigError) {
    console.log(sigError)
  }

Last updated