const cf = await ethers.getContractFactory('DasomContract');
const dasomContract = await cf.deploy();
if (!(await dasomContract.deployed())) {
throw new Error(
'Error occurred during deploying the contract',
);
}
[태그:] getContractFactory
[ethers.js] bytecode(=creationCode) 얻기
contract 컴파일 후 bytecode(creationCode)를 얻으려면:
(await ethers.getContractFactory("DasomOLIContract")).bytecode
이걸 keccak256()으로 돌리면(ethersV5 기준)
> ethers.utils.keccak256((await ethers.getContractFactory("DasomOLIContract")).bytecode)
위는 solidity에서 다음을 하는 것과 동일하다.
keccak256(abi.encodePacked(type(DasomOLIContract).creationCode));
[ethers.js] Contract Function 실행
const DasomOLI = ethers.getContractFactory('DasomOLI');
const dasomoli = DasomOLI.attach('0x1234567890123456789012345678901234567890');
dasomoli.functionDasom();