Last active
November 4, 2018 23:17
-
-
Save joaoaguiam/a4ae2a79a5b8d4778bfdfb2ba9af0e60 to your computer and use it in GitHub Desktop.
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
const abi = require('ethereumjs-abi') | |
const BN = require('bn.js') | |
const Web3 = require('web3'); | |
const account = web3.eth.accounts.privateKeyToAccount(privateKey); | |
let messageHash = "0x" + abi.soliditySHA3( | |
["address", "uint", "uint"], | |
[new BN(userAddress, 16), new BN(String(stakeAmount), 10), new BN(String(expiryDate), 10)] | |
).toString("hex"); | |
let signedMessage = account.sign(messageHash); | |
response.json({ | |
expiryDate, | |
stakeAmount, | |
messageHash: signedMessage.messageHash, | |
signature: signedMessage.signature, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment