Last active
May 26, 2020 13:01
-
-
Save leviadam/53a79f5ddb9810e2af5a7fae9c2b76df 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
safeContract.getTransactionHash(myToAddress,1000,NULL_HASH,0,0,0,0,NULL_ADDRESS,NULL_ADDRESS,0) | |
.then( | |
(hashedTx) => { | |
console.log("Hashed Tx:", hashedTx); | |
let binHashedTx = ethers.utils.arrayify(hashedTx); | |
console.log("binHashedTx:", binHashedTx); | |
wallet.signMessage(binHashedTx) | |
.then( | |
(signature) => { | |
console.log("signature:", signature); | |
let splitSig = ethers.utils.splitSignature(signature); | |
console.log("split signature:", splitSig); | |
// Add 4: | |
console.log("finalSig:", signature.replace(/1b$/,"1f").replace(/1c$/,"20")); | |
// Output: | |
// signature: 0x8144a24b5e28e8b383287146c4f263172e2f5ca55d84e3ea6dcd5e166770b4944277fd325e907eef33ea4a43b57c56646945624fba4b7f3027e81ae2f815c4a31c | |
// split signature: { | |
// r: '0x8144a24b5e28e8b383287146c4f263172e2f5ca55d84e3ea6dcd5e166770b494', | |
// s: '0x4277fd325e907eef33ea4a43b57c56646945624fba4b7f3027e81ae2f815c4a3', | |
// recoveryParam: 1, | |
// v: 28 | |
// } | |
// finalSig: 0x8144a24b5e28e8b383287146c4f263172e2f5ca55d84e3ea6dcd5e166770b4944277fd325e907eef33ea4a43b57c56646945624fba4b7f3027e81ae2f815c4a320 | |
} | |
) | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment