Skip to content

Commit 45f1000

Browse files
committed
feat: add script for batcher contract deploy
Ticket: COIN-956
1 parent 9a93e13 commit 45f1000

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const config: HardhatUserConfig = {
6666
loggingEnabled: false
6767
},
6868
eth: {
69-
url: `https://ultra-empty-sanctuary.quiknode.pro/${QUICKNODE_ETH_MAINNET_API_KEY}`,
69+
url: `https://ethereum-rpc.publicnode.com`,
7070
accounts: [`${PRIVATE_KEY_FOR_V4_CONTRACT_DEPLOYMENT}`]
7171
},
7272
hteth: {

scripts/deployBatcherContract.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { ethers } from 'hardhat';
2+
const hre = require('hardhat');
3+
const fs = require('fs');
4+
5+
async function main() {
6+
const output = {
7+
walletImplementation: '',
8+
walletFactory: '',
9+
forwarderImplementation: '',
10+
forwarderFactory: '',
11+
batcher: ''
12+
};
13+
14+
const contractName = 'Batcher';
15+
const transferGasLimit = '200000';
16+
17+
const Batcher = await ethers.getContractFactory(contractName);
18+
const batcher = await Batcher.deploy(transferGasLimit);
19+
await batcher.deployed();
20+
output.batcher = batcher.address;
21+
console.log('Batcher deployed at ' + batcher.address);
22+
23+
fs.writeFileSync('output.json', JSON.stringify(output));
24+
25+
// Wait 5 minutes. It takes some time for the etherscan backend to index the transaction and store the contract.
26+
console.log('Waiting for 5 minutes before verifying.....');
27+
await new Promise((r) => setTimeout(r, 1000 * 300));
28+
29+
console.log('Done waiting, verifying');
30+
await verifyContract(contractName, batcher.address, [transferGasLimit]);
31+
console.log('Contracts verified');
32+
}
33+
34+
async function verifyContract(
35+
contractName: string,
36+
contractAddress: string,
37+
constructorArguments: string[],
38+
contract?: string
39+
) {
40+
try {
41+
const verifyContractArgs: {
42+
address: string;
43+
constructorArguments: string[];
44+
contract?: string;
45+
} = {
46+
address: contractAddress,
47+
constructorArguments: constructorArguments
48+
};
49+
50+
if (contract) {
51+
verifyContractArgs.contract = contract;
52+
}
53+
54+
await hre.run('verify:verify', verifyContractArgs);
55+
} catch (e) {
56+
// @ts-ignore
57+
// We get a failure API response if the source code has already been uploaded, don't throw in this case.
58+
if (!e.message.includes('Reason: Already Verified')) {
59+
throw e;
60+
}
61+
}
62+
console.log(`Verified ${contractName} on Etherscan!`);
63+
}
64+
65+
main().catch((error) => {
66+
console.error(error);
67+
process.exitCode = 1;
68+
});

0 commit comments

Comments
 (0)