generated from 0xJuancito/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path18-MagicNum.ts
26 lines (20 loc) · 843 Bytes
/
18-MagicNum.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
import { ethers } from "hardhat";
const CONTRACT_ADDRESS = "0xb45adaFDeE7Dd85cAc0De94fD1475b25782e5B75";
const CONTRACT_NAME = "MagicNum";
async function main() {
const factory = await ethers.getContractFactory(CONTRACT_NAME);
const contract = factory.attach(CONTRACT_ADDRESS);
const initOpcode = "600a600c600039600a6000f3";
const runtimeOpcode = "602a60805260206080f3";
const bytecode = `0x${initOpcode}${runtimeOpcode}`;
const abi = ["function whatIsTheMeaningOfLife() pure returns (uint)"];
const byteFactory = new ethers.ContractFactory(abi, bytecode, ethers.provider.getSigner());
const byteContract = await byteFactory.deploy();
await byteContract.deployed();
const tx = await contract.setSolver(byteContract.address);
await tx.wait();
}
main().catch(error => {
console.error(error);
process.exit(1);
});