As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [create2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
18 views

How to know if a smart contract is calling a function or if it is an EOA?

Some have suggested detecting the contract bytecode size but this can be spoofed in the constructor where the value will be 0 for an EOA and a contract. Then with create2 and self destruct the problem ...
Nat's user avatar
  • 223
0 votes
0 answers
17 views

Calculate the contract address created using create2 with dynamic byte string as a salt

EIP-1014 describes salt as bytes32. However, the function create2 written in assembly allows passing byte string of arbitrary size as the salt parameter. Example function deploy(bytes memory bytecode, ...
Ivan Zakharov's user avatar
0 votes
0 answers
22 views

Different address using Create2 due to difference in byteCode(type(ERC1967Proxy).creationCode and ethers.getContractFactory("ERC1967Proxy").bytecode

I am currently facing an issue while trying to calculate the address of a SimpleAccount contract using getCreate2Address() from ethers.utils in JavaScript. I noticed that the address I receive is ...
kannu's user avatar
  • 11
1 vote
1 answer
86 views

Extracting salt from tx's to the CREATE2 deployer contract 0x4e59b44847b379578588920ca78fbf26c0b4956c

I've noticed a pattern in deploying CREATE2 contracts and now I'm trying to find out the salt used. The reason is, for verifying contracts with CREATE2 on Sourcify salt and the deployerAddress are ...
kuzdogan's user avatar
  • 587
2 votes
1 answer
180 views

Deploying smart contract using CREATE2, bytecode, salt - getting different addresses on different chains?

I would like to deploy the same contract to multiple chains under the same address using CREATE2. DeterministicDeployFactory: https://docs.alchemy.com/docs/create2-an-alternative-to-deriving-contract-...
Mars Robertson's user avatar
1 vote
0 answers
151 views

What are the differences between create2 and create3?

Which strategies should we follow when using create2 and create3? I had seen that li.fi deployed the contracts using create3 factory contract. and i know some basics about create that we can find out ...
0xbeny's user avatar
  • 128
6 votes
1 answer
206 views

Why Uniswap V3 factory saves parameters to storage and then deletes them instead of passing parameters to pool constructor directly

In the UniswapV3 contracts we can see that when creating a new pool, instead of passing parameters to the pool contract, we actually deploy the pool contract, and in the pool contract's constructor it ...
Patrick Collins's user avatar
0 votes
2 answers
30 views

Determing value of ERC-20 token

In developing a new ERC-20 token, can you determine the value of the token? Can you make them worth a different fraction of an ethereum?
HoboJeff's user avatar
2 votes
1 answer
84 views

How to tell if code is already deployed by create2 at an address

We have a factory creating clones using create2, using OpenZeppelin's Clones (https://docs.openzeppelin.com/contracts/4.x/api/proxy#Clones-cloneDeterministic-address-bytes32-). Is it possible to know ...
Alexander Kondratskiy's user avatar
1 vote
1 answer
79 views

What happens if by randomness you deploy a contract to the same address then an existing EOA

What happens if by randomness you deploy a contract to the same address then an existing EOA? Would the deployment be rejected? Would it only be rejected if the EOA has no transaction history i.e a ...
FreddyC's user avatar
  • 151
0 votes
0 answers
322 views

getCreate2Address (create2) UNABLE to get correct contract address :(

UPDATE: I think the real question is what to use as Init code? The contract has no constructor. Can someone help on this? Basically i am using openzeppelin Clones.sol contract to determine the ...
smenir443's user avatar
  • 105
0 votes
0 answers
29 views

spend child contract(deployed by mother contract) from mother contract?

I have created a smart contract like this : contract ChildContract { function sendTokenTo(uint _amount, ITRC20 _token, address payable _receiver) external payable onlyOwner { ...
Hamid Naghipour's user avatar
1 vote
1 answer
534 views

How difficult is it to deploy a contract to one specific address that you want?

Let's consider two scenarios: Address X deployed Uniswap code to ETH mainnet with Create2 opcode to address Y Address X deployed Uniswap code to ETH mainnet with Create opcode to address Z I am an ...
Patrick Collins's user avatar
4 votes
2 answers
323 views

Convert EOA to contract account

EIP-2026 mentions several ways of creating a new account. One way is by: (...) converting a non-countract account into a contract account (...) Is this a hypothetical scenario or could this be done ...
Markus Schick's user avatar
1 vote
2 answers
243 views

How to determine if a contract with a create2 address exists?

Say I have a factory contract that creates child contracts using create2 where a child contract may have never existed or may have existed but no longer exists by for example self-destructing, how can ...
MShakeG's user avatar
  • 573
0 votes
1 answer
69 views

Create2 gives different addresses on different networks

I'm trying to deploy a contract on two networks with the create2 method. I'm using same arguments in Goerli and Rinkeby, however I'm still getting two different addresses for the same contract. Here ...
yieniggu's user avatar
  • 121
0 votes
1 answer
229 views

how to deploy a contract by sending ether to it's address

I'm trying to build a payment gateway and I generated address of a contract before deploying it with create2. how to deploy the contract by sending ether to new generated address? pragma solidity 0.8....
Meysam's user avatar
  • 81
1 vote
1 answer
224 views

CREATE2 opcode offset and size

This is the UniswapV2Factory contract createPair function. I know that create2 opcode takes 4 arguments (value, offset , size , salt) How add(bytecode,32) can give the offset ? How mload(bytecode) can ...
Mehmet Akifhan Ilgaz's user avatar
0 votes
1 answer
826 views

Deploy contract with Bytecode from smart contract

I have a contract that has a function deployContract(bytes memory runtimeBytecode) I want this function to be able to deploy the bytes sent to it as a new smart contract. I understand that I will have ...
maxime's user avatar
  • 96
2 votes
0 answers
489 views

Can one still bypass EIP-155 and deploy to the same chain-independent address from an EOA

I was trying to deploy a contract to a deterministic address using Nicks method. This works fine on Rinkeby and all the Ethereum-Testnets that I tried. However, it doesn't work on Mumbai and probably ...
Marlo's user avatar
  • 273
1 vote
1 answer
346 views

Gas cost of Create2

I code a very simple program to test create2(). The program has two contracts, an empty firstContract, and a test contract to deploy firstContract via create2. The codes are below. Then I call ...
LeoZ's user avatar
  • 11
0 votes
4 answers
477 views

Why does create2 predicted address not equal actual address?

For some reason the predicted/pre-computed address is not equal to the actual address when the created contract accepts address for it's constructor parameters, however it's fine when the constructor ...
MShakeG's user avatar
  • 573
2 votes
2 answers
2k views

how to precalcuate the deployed contract address

// SPDX-License-Identifier: MIT pragma solidity ^0.5.16; import "https://github.com/Uniswap/v2-core/blob/master/contracts/UniswapV2Pair.sol"; contract TestERC20 { address public _pair =...
hobbydev's user avatar
  • 143
0 votes
1 answer
646 views

EXTCODESIZE returning 32 for contract size less than 32

I'm currently completing the Ethernaut challenges, one of them is to deploy a small contract (runtime bytecode is 10 bytes long). I'm running the tests on my local machine, and using Solidity to ...
riordant's user avatar
1 vote
1 answer
391 views

Is there a size limitation on create2 bytecode field?

I have the following method in my Solidity contract. function deploy(bytes memory bytecode, uint _salt) public payable returns (address){ address addr; assembly { addr := create2( ...
Armen's user avatar
  • 13
3 votes
1 answer
390 views

Security Implications of CREATE2 and SELFDESTRUCT

I was reading a discussion on the topic, i have two questions it is commented The SELFDESTRUCT and recreation cannot happen within one transaction, due to how SELFDESTRUCT operates. could someone ...
Stormsson's user avatar
  • 371
2 votes
1 answer
717 views

is it possible to create smart contract with deterministic address (like CREATE2 does) from transaction itself (i.e. without proxy/creator smart c)?

I found that From ethereum yellow whitepaper Transaction contains fields: nonce gasPrice gasLimit to value v, r, s init (contains "smart contract creation code" that should return "...
srghma's user avatar
  • 181
3 votes
2 answers
453 views

How to prevent front-running the salt when using CREATE2?

I was looking at Optionality's clone-factory, which is based off EIP-1167, and wondering whether it can be ported to use CREATE2. One concern is that a third-party could, in theory, "front-run&...
Paul Razvan Berg's user avatar
1 vote
1 answer
403 views

Using the contract owner as the salt for CREATE2

I have a factory contract, which creates child contracts. The child contract inherits from OpenZeppelin's Ownable, so it has an owner and a transferOwnership method. The factory contract uses CREATE2 ...
Paul Razvan Berg's user avatar
12 votes
1 answer
7k views

What is the benefit of using create2() to create a smart contract?

Why would someone use create2() inline assembly code to create a child contract in factory pattern as opposed to using newContract() to create an instance of "newContract"? What are the ...
YulePale's user avatar
  • 1,693
1 vote
1 answer
2k views

Calculate deterministic address with Create2 when cloning contract with Factory pattern

There is an existing unanswered question from another author with the same problem, I am creating a more detailed one with the hopes both can be closed. I have a solidity contract based on the ideas ...
Franco's user avatar
  • 156
9 votes
2 answers
2k views

Can CREATE2 with the same salt override existing contract?

Deployed: https://rinkeby.etherscan.io/address/0x121e370ae349425d0d744f6db43c2f43e777f972#code pragma solidity 0.8.3; contract Test { uint256 public a; constructor (uint256 _a) public { ...
Mars Robertson's user avatar
5 votes
1 answer
731 views

How to implement the CREATE2 in Python

I'd like to know either how to implement the skinny CREATE2 in Python or a package that provides it. This is the function I'm trying to port from TypeScript to Python. It calls generateAddress2 with ...
vnavascues's user avatar
1 vote
0 answers
29 views

Is there a way to deploy contracts with circular reference in 2 steps using create2?

Circular reference meaning contracts know each other addresses. So instead of deploy foo deploy bar(foo.address) foo.init(bar.address) Use some clever tricks to have only 2 deploy steps without an ...
Poma's user avatar
  • 171
1 vote
1 answer
2k views

Why does the creationCode of this contract change if a change is made in the importing contract?

For the following: pragma solidity >=0.5.0; contract Include { uint z = 1; } contract CreationCode { uint k = 1; function get() external returns (bytes32) { return keccak256(...
Joël's user avatar
  • 1,670
2 votes
0 answers
162 views

How i can calculate deterministic address from contract clone (create2) [duplicate]

Is there any way to calculate the deterministic address of a contract cloned by a Factory through create2? I have this contract Factory contract ForwarderFactory { function cloneForwarder(address ...
Gustavo Toledo's user avatar
1 vote
1 answer
1k views

How to calculate CREATE2 address in golang?

I have a factory pattern smart contract that creates other smart-contracts by cloning the master smart contract via Minimal Proxy Contract and CREATE2 opcode. What is the proper way to calculate ...
navigante's user avatar
12 votes
4 answers
5k views

Is it possible to batch approve + transfer an ERC-20 token?

In our dapp, we currently have the following user flow: Approve the Sablier contract to spend up to x ERC20 tokens Transfer the x ERC20 tokens to the Sablier contract This is not super bad UX, but ...
Paul Razvan Berg's user avatar
3 votes
1 answer
567 views

Can I use create2 to deploy minimal proxies in solidity, without using assembly?

Solidity 0.6.2 allows the creation of contracts with the create2 opcode via the new keyword and passing a salt in addition to any args. This is adequate for creating standard contracts, but what if I ...
Nick Furfaro's user avatar
7 votes
2 answers
3k views

Is it possible to deploy a contract using create2 in Solidity?

Can I deploy a contract in Solidity (not in-line assembly) using create2?
Shane Fontaine's user avatar
1 vote
1 answer
314 views

Does create2 increase the nonce of the computed contract’s deployment address?

Simple question about create2 failure. Does create2 increase the nonce of the computed contract’s deployment address ? Or does the first nonce increment operation happens after the first call to the ...
user2284570's user avatar
5 votes
1 answer
404 views

How does eip1014 (create2) make collisions possible?

In the Clarifications section of EIP 1014 (create2) it says that "This EIP makes collisions possible." It doesn't explain how collisions are now possible, but it links to EIP 684 (Prevent ...
elopio's user avatar
  • 442
129 votes
7 answers
66k views

How is the address of an Ethereum contract computed?

How is the address of an Ethereum contract computed? What use cases are there for knowing a contract's address in advance?
eth's user avatar
  • 83.3k