Skip to content

Instantly share code, notes, and snippets.

@snario
Created August 20, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snario/df3bd28901bf707206f43fd543d50a5e to your computer and use it in GitHub Desktop.
Save snario/df3bd28901bf707206f43fd543d50a5e to your computer and use it in GitHub Desktop.
const ethers = require("ethers");
const getAddress = ethers.utils.getAddress;
const solidityKeccak256 = ethers.utils.solidityKeccak256;
const keccak256 = ethers.utils.keccak256;
const solidityPack = ethers.utils.solidityPack;
const Interface = ethers.utils.Interface;
const defaultAbiCoder = ethers.utils.defaultAbiCoder;
const hexDataSlice = ethers.utils.hexDataSlice;
// Double checked with type(Proxy).creationCode
const creationCode =
"0x608060405234801561001057600080fd5b506040516101b43803806101b48339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806101906024913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506077806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054163660008037600080366000845af43d6000803e6000811415603d573d6000fd5b3d6000f3fea265627a7a723058202b014062fac5bbf2f3a320134dac5811a29f916a0f071e16e4493bf4a28fe8a064736f6c634300050a0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564";
// https://kovan.etherscan.io/tx/0xf7e1f6aa581c20391d1af2035e1536e531997ed55d0f547e4d486b5ca6c3c4eb
const multisigAddr = "0xe3ca38e42cf5469a17ad8f473e45521bee930ae";
const proxyFactoryAddress = "0xd891f41c4ba30b1ff4f604e30f64ae387dd85b4f";
const multisigOwners = [
"0x4eecd845f1f6dd541c4ef07290423a7928a38520",
"0x50edbe51a113bcc181725c3c3c2f7e124f900e78"
];
const initializer = new Interface(["setup(address[])"]).functions.setup.encode([
multisigOwners
]);
const salt = keccak256(
solidityPack(["bytes32", "uint256"], [keccak256(initializer), 0])
);
const deploymentData = solidityPack(
["bytes", "uint256"],
[creationCode, multisigAddr]
);
getAddress(
hexDataSlice(
keccak256(
solidityPack(
["uint8", "address", "uint256", "bytes32"],
["0xff", proxyFactoryAddress, salt, keccak256(deploymentData)]
)
),
12
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment