scroll-tech / scroll-guides

MIT License
43 stars 180 forks source link

create2 example seems not work #5

Closed yanyanho closed 11 months ago

yanyanho commented 12 months ago

I try code as below and found that the calculated contract address is not match the deployed contract address.


const factoryContractDeployer = await ethers.getContractFactory("ExampleContractFactory"); const contractDeployer = await ethers.getContractFactory("ExampleContract"); const factoryContractdeployed = await factoryContractDeployer.deploy()

const exampleParam = 1
const salt = 1

const exampleContractBytecode = await factoryContractdeployed.getBytecode(exampleParam);
console.log("bytecode" , exampleContractBytecode)

const contractAddress = await factoryContractdeployed.getAddress(exampleContractBytecode, salt);
console.log("contract address calculated",contractAddress)

const contract = await contractDeployer.attach(contractAddress)

const deploy = await factoryContractdeployed.deployDeterministically(exampleParam,salt)

const receipt = await deploy.wait();

console.log("Factory deployed to:", receipt.events[0].args.contractAddress);
yanyanho commented 12 months ago

receipt.events[0].args.contractAddress != contractAddress

Turupawn commented 12 months ago

Thanks for the heads up @yqrashawn I can confirm the example is not working. I sent a fix PR at #6 @razacodespython or @dghelm can you guys help me reviewing and merging my PR