Skip to content

Instantly share code, notes, and snippets.

@fsjuhl
Last active October 16, 2023 22:36
Show Gist options
  • Save fsjuhl/3e18d483348a3e3af62be34692c4ecd4 to your computer and use it in GitHub Desktop.
Save fsjuhl/3e18d483348a3e3af62be34692c4ecd4 to your computer and use it in GitHub Desktop.
Snippet of the SVS antibot server-side code.
const crypto = require("crypto")
const web3 = new (require("web3"))()
const PRIVATE_KEY = "0x"
const account = "0x", amount = 3
const nonce = crypto.randomBytes(9).toString("base64")
const content = web3.utils.soliditySha3({
type: "address",
value: account
}, {
type: "uint256",
value: amount
}, {
type: "string",
value: nonce
})
const { messageHash: hash, signature } = await web3.eth.accounts.sign(content, PRIVATE_KEY)
return { hash, signature, nonce }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment