Skip to content

Instantly share code, notes, and snippets.

@plutoegg
Created October 4, 2018 14:00
Show Gist options
  • Save plutoegg/304404979b3fd704de9609bd7c163f12 to your computer and use it in GitHub Desktop.
Save plutoegg/304404979b3fd704de9609bd7c163f12 to your computer and use it in GitHub Desktop.
Trustless Developer Guide - Authentication Example
// This example shows how to generate the signature from a raw private key
// Signing using hardware wallets such as Ledger or Trezor can be done using their documentation
const ethUtils = require('ethereumjs-utils')
const privKey = /* Your Private Key */
const nonce = ((Date.now() / 1000) + 350) + ''
const hash = ethUtils.hashPersonalMessage(ethUtils.toBuffer(nonce.toString(16)))
const signature = ethUtils.ecsign(hash, privKey)
const response = await efx.contract.unlock(token, amount, nonce, signature)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment