Created
October 4, 2018 14:00
-
-
Save plutoegg/304404979b3fd704de9609bd7c163f12 to your computer and use it in GitHub Desktop.
Trustless Developer Guide - Authentication Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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