我希望使用CREATE2将相同的契约部署到同一地址下的多个链中。
DeterministicDeployFactory:https://docs.alchemy.com/docs/create2-an-alternative-to-deriving-contract-addresses
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract DeterministicDeployFactory {
event Deploy(address addr);
function deploy(bytes memory bytecode, uint _salt) external {
address addr;
assembly {
addr := create2(0, add(bytecode, 0x20), mload(bytecode), _salt)
if iszero(extcodesize(addr)) {
revert(0, 0)
}
}
emit Deploy(addr);
}
}塞波里亚:https://sepolia.etherscan.io/address/0x3311fff00a0b7553f127b5b25397e12cb268f919#code
戈里:https://goerli.etherscan.io/address/0x34d32ac4ed0cef66bbc638781b97fa6b494b98e0#code
然后,我编译了一个简单的契约storage.sol,这是打开Remix时的默认契约。
字节码:0x608060405234801561001057600080fd5b50610150806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b60405161005091906100a1565b60405180910390f35b610073600480360381019061006e91906100ed565b61007e565b005b60008054905090565b8060008190555050565b6000819050919050565b61009b81610088565b82525050565b60006020820190506100b66000830184610092565b92915050565b600080fd5b6100ca81610088565b81146100d557600080fd5b50565b6000813590506100e7816100c1565b92915050565b600060208284031215610103576101026100bc565b5b6000610111848285016100d8565b9150509291505056fea2646970667358221220522334dfd7decc643eeb644e28d6d7f11bae5f5b74d14e33980a35d12bc7771f64736f6c63430008110033
盐:17
Sepolia部署TX:https://sepolia.etherscan.io/tx/0xdbe937835979c53b840a5737fe65b9ab93368ff53275e4787cf3ef73fe533a1a
Sepolia部署的存储:https://sepolia.etherscan.io/address/0x8C4201833590b5F93c813847b24902bFf7131FDF
Goerli部署TX:https://goerli.etherscan.io/tx/0x4c92195afbfca1630e9d7f73ca13e190e36c19d5d8eff8397d9e4d7b1b104a82
Goerli部署的存储:https://goerli.etherscan.io/address/0xB38f04cb936E19AB9B8F09b15122668c1F9f77e3
我不明白为什么Sepolia上部署的地址与Goerli上的地址不同。


DeterministicDeployFactory字节码和盐是一样的..。
工厂:https://goerli.etherscan.io/address/0x1dd764cf61c8e56ea048374fece83ffa40616569#code
工厂https://sepolia.etherscan.io/address/0x1dd764cf61c8e56ea048374fece83ffa40616569
存储:https://goerli.etherscan.io/address/0x8bB256467BfE67b8add96002ffe1B05350bFfA57#code
存储:https://sepolia.etherscan.io/address/0x8bB256467BfE67b8add96002ffe1B05350bFfA57#code
发布于 2023-02-20 16:01:02
确定的合同地址取决于工厂的合同地址。在您的例子中,DeterministicDeployFactory的合同地址。如果DeterministicDeployFactory的值在所有其他链中是相同的,当然,二萜契约的智能契约将是相同的。
https://ethereum.stackexchange.com/questions/145282
复制相似问题