1
0
stack-orchestrator/app/data/container-build/cerc-optimism-contracts/hardhat-tasks/rekey-json.ts
prathamesh0 be08ee81ea Add ability to run Optimism fixturenet with external L1 endpoint (#273)
* Remove unnecessary todos

* Set option to log commands in shell scripts

* Replace fixturenet-eth dependency with wait on endpoint

* Skip lighthouse node dependency check

* Update all services in the stack

* Use debug flag to enable shell commands logging

* Add bash in op-batcher container

* Update mobymask-v2 instructions

* Update fixturenet-optimism instructions

* Add descriptions for services

* Move ts files to container-build

* Take L1 RPC endpoint from the env file

* Add dev mode restriction for editing env file

Former-commit-id: 2515878eeb3456147d4e50e1b39c98f618d1a3d3
2023-04-04 14:53:28 +05:30

29 lines
1.0 KiB
TypeScript

import fs from 'fs'
import { task } from 'hardhat/config'
import { hdkey } from 'ethereumjs-wallet'
import * as bip39 from 'bip39'
task('rekey-json', 'Generates a new set of keys for a test network')
.addParam('output', 'JSON file to output accounts to')
.setAction(async ({ output: outputFile }) => {
const mnemonic = bip39.generateMnemonic()
const pathPrefix = "m/44'/60'/0'/0"
const labels = ['Admin', 'Proposer', 'Batcher', 'Sequencer']
const hdwallet = hdkey.fromMasterSeed(await bip39.mnemonicToSeed(mnemonic))
const output = {}
for (let i = 0; i < labels.length; i++) {
const label = labels[i]
const wallet = hdwallet.derivePath(`${pathPrefix}/${i}`).getWallet()
const addr = '0x' + wallet.getAddress().toString('hex')
const pk = wallet.getPrivateKey().toString('hex')
output[label] = { address: addr, privateKey: pk }
}
fs.writeFileSync(outputFile, JSON.stringify(output, null, 2))
console.log(`L2 account keys written to ${outputFile}`)
})