Skip to content

Commit

Permalink
add generate tokens script
Browse files Browse the repository at this point in the history
  • Loading branch information
backmeupplz committed Aug 22, 2023
1 parent d3cf151 commit e9fa0f3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion merkleTrees
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"release": "np",
"prepublishOnly": "yarn build && yarn tsc --skipLibCheck",
"set-current-token-id": "yarn hardhat run --network deploy scripts/set-current-token-id.ts",
"set-max-entanglements": "yarn hardhat run --network deploy scripts/set-max-entanglements.ts"
"set-max-entanglements": "yarn hardhat run --network deploy scripts/set-max-entanglements.ts",
"generate-tokens": "yarn hardhat run scripts/generate-tokens.ts"
},
"devDependencies": {
"@ethersproject/providers": "^5.7.2",
Expand Down
25 changes: 25 additions & 0 deletions scripts/generate-tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { randomBytes } from 'crypto'
import prompt from 'prompt'

function getRandomNumber() {
const value = randomBytes(32) // 32 bytes = 256 bits
const bigInt = BigInt(`0x${value.toString('hex')}`)
return `${bigInt}`
}

void (async function main() {
const { count } = await prompt.get({
properties: {
count: {
required: true,
type: 'number',
description: 'How many tokens do you want to generate?',
},
},
})
console.log(`Generating ${count} tokens...`)
for (let i = 0; i < count; i++) {
console.log(`token:${getRandomNumber()}`)
}
console.log('Done!')
})()

0 comments on commit e9fa0f3

Please sign in to comment.