generated from rmrk-team/evm-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ts
executable file
·62 lines (52 loc) · 2.68 KB
/
deploy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { delay } from '@nomiclabs/hardhat-etherscan/dist/src/etherscan/EtherscanService';
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { run } from 'hardhat';
import { Film, Character } from '../typechain-types';
import { Wallet, utils } from 'zksync-web3';
import * as ethers from 'ethers';
export default async function (hre: HardhatRuntimeEnvironment) {
console.log('Deploying smart film contract');
const wallet = new Wallet(process.env.PRIVATE_KEY || '');
// Create deployer object and load the artifact of the contract you want to deploy.
const deployer = new Deployer(hre, wallet);
const filmArtifact = await deployer.loadArtifact('Film');
const filmArgs = ['Pet Projects', 'PET', 10_000];
// const filmArgs = ['Charge', 'CHARGE', 10_000];
// const filmArgs = ['Sprite Fright', 'SPRITE', 10_000];
// const filmArgs = ['Coffee Run', 'COFFEE', 10_000];
// const filmArgs = ['Spring', 'SPRING', 10_000];
// const filmArgs = ['Caminandes Llamigos', 'CAMINANDES', 10_000];
// Estimate contract deployment fee
const filmDeploymentFee = await deployer.estimateDeployFee(filmArtifact, filmArgs);
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`.
const parsedFee = ethers.utils.formatEther(filmDeploymentFee.toString());
console.log(`The deployment is estimated to cost ${parsedFee} ETH`);
const film = <Film>await deployer.deploy(filmArtifact, filmArgs);
await film.deployed();
console.log(`Sample contracts deployed to ${film.address}.`);
// Deployment of Character smart contract
console.log('Deploying Character smart contract');
const characterArtifact = await deployer.loadArtifact('Character');
const characterArgs = ['Cat', 'CAT'];
// const characterArgs = ['Dog', 'DOG'];
// const characterArgs = ['Pitch', 'PITCH'];
const characterDeploymentFee = await deployer.estimateDeployFee(characterArtifact, characterArgs);
const parsedCharacterFee = ethers.utils.formatEther(characterDeploymentFee.toString());
console.log(`The deployment is estimated to cost ${parsedCharacterFee} ETH`);
const character = <Character>await deployer.deploy(characterArtifact, characterArgs);
await character.deployed();
console.log(`Character smart contract deployed to ${character.address}.`);
await delay(20000);
console.log('Will verify now');
await run(`verify:verify`, {
address: film.address,
constructorArguments: filmArgs,
contract: 'contracts/Film.sol:Film',
});
await run(`verify:verify`, {
address: character.address,
constructorArguments: characterArgs,
contract: 'contracts/Character.sol:Character',
});
}