Create wallets
Set up wallet contracts¶
Clone the wallet contracts from the zkevm-contracts
repository and install the npm
libraries.
git clone https://github.com/0xPolygonHermez/zkevm-contracts.git
cd ~/zkevm-contracts
npm i
Create wallets¶
-
Create a
wallets.js
file.cd ~/zkevm-contracts nano wallets.js
-
Copy/paste the JavaScript code below.
const ethers = require("ethers"); async function main() { const arrayNames = [ "## Deployment Address", "\\n\\n## Trusted sequencer", "\\n\\n## Trusted aggregator", ]; for (let i = 0; i < arrayNames.length; i++) { const wallet = ethers.Wallet.createRandom(); console.log(arrayNames[i]); console.log(`Address: ${wallet.address}`); console.log(`PrvKey: ${wallet._signingKey().privateKey}`); console.log(`mnemonic: "${wallet._mnemonic().phrase}"`); const keystoreJson = await wallet.encrypt("password"); console.log(`keystore: ${keystoreJson}`); } } main().catch((e) => { console.error(e); process.exit(1); });
-
Generate the wallets.
node wallets.js | tee wallets.txt
Prepare environment variables¶
-
Edit the environment variables file.
cp .env.example .env # copies .env.example file into .env nano .env # opens .env file for editing
-
Set the following variables.
MNEMONIC="..." # from wallets.txt Deployment Address mnemonic INFURA_API_KEY="..." # your API Key from Infura account ETHERSCAN_API_KEY="..." # your Etherscan API key
-
Send 0.5 Sepolia ETH to the deployment address wallet listed in
wallets.txt
.
Edit deployment configuration¶
-
Open the
deploy-parameters.json
file.cd ~/zkevm-contracts/deployment cp deploy_parameters.json.example deploy_parameters.json nano deploy_parameters.json
-
Edit the following parameters to match the generated wallet parameters.
trustedSequencer
: trusted sequencer address inwallets.txt
.trustedAggregator
: trusted aggregated address inwallets.txt
.admin
: deployment address inwallets.txt
.zkEVMOwner
: deployment address inwallets.txt
.timelockAddress
: deployment address inwallets.txt
.initialZkEVMDeployerAddress
: deployment address inwallets.txt
.zkEVMDeployerAddress
: deployment address inwallets.txt
.
Deploy contracts¶
-
cd
back tozkevm-contract
root directory and run the deployment scripts.Tip
It might be helpful to run these one at a time.
cd .. npm i @openzeppelin/hardhat-upgrades npm run deploy:deployer:ZkEVM:goerli npm run verify:deployer:ZkEVM:goerli npm run prepare:testnet:ZkEVM:goerli && npm run deploy:ZkEVM:test:goerli npm run verify:ZkEVM:goerli
You should see output that looks something like this at the start each time:
> @0xpolygonhermez/zkevm-contracts@3.0.0 deploy:deployer:ZkEVM:goerli > npx hardhat run deployment/2_deployPolygonZKEVMDeployer.js --network goerli ####################### polygonZkEVMDeployer deployed on: 0x8c4e69A65f84D5Ee0d83095916706Be74C133571
Info
The scripts auto-deploy the MATIC token contract and the
zkEVMDeployer
contract if required. -
Check the deployment was successful on Etherscan.
https://goerli.etherscan.io/address/[deployment-address] <!-- from `wallets.txt` -->