How to use the eth-connect.toHex function in eth-connect

To help you get started, weā€™ve selected a few eth-connect examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github decentraland / explorer / kernel / packages / shared / ethereum / EthereumService.ts View on Github external
export async function signMessage(messageDict: MessageDict) {
  const signerAccount = await getUserAccount()
  if (!signerAccount) {
    throw new Error(`Not a web3 game session`)
  }

  const messageToSign = await messageToString(messageDict)

  if (messageToSign.indexOf('# DCL Signed message') === -1) {
    throw new Error(`Message is not in a right format.`)
  }

  const hexEncodedMessage = toHex(messageToSign)

  try {
    const signature = await requestManager.personal_sign(hexEncodedMessage, signerAccount, '')
    return { message: messageToSign, hexEncodedMessage, signature }
  } catch (err) {
    throw new Error(err)
  }
}

eth-connect

Ethereum TypeScript API, middleware to talk to a ethereum node using an async provider

LGPL-3.0
Latest version published 5 months ago

Package Health Score

66 / 100
Full package analysis