scroll-tech / scroll-guides

MIT License
47 stars 213 forks source link

create2 example seems not work #5

Closed yanyanho closed 1 year ago

yanyanho commented 1 year 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 1 year ago

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

Turupawn commented 1 year 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