Questions tagged [create2]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
35 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....
user avatar
  • 21
0 votes
1 answer
40 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 ...
user avatar
0 votes
0 answers
24 views

ERC721 function deployed with create2 stops working after a particular function is called

So I'm working on an NFT marketplace smart contract and one of the features in this marketplace allows users to deploy their own collection (this is basically a smart contract that extends the ERC721 ...
user avatar
0 votes
1 answer
59 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 ...
user avatar
  • 56
0 votes
0 answers
71 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 ...
user avatar
  • 179
1 vote
1 answer
47 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 ...
user avatar
  • 11
0 votes
3 answers
143 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 ...
user avatar
  • 230
0 votes
0 answers
18 views

How to precompute create2 contract address in js? [duplicate]

I'd like to precompute the address for a contract that may be created using create2 in javascript. Say I have the following Factory contract that creates contracts with create2 as follows, how would I ...
user avatar
  • 230
2 votes
2 answers
434 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 =...
user avatar
  • 123
0 votes
1 answer
119 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 ...
user avatar
1 vote
1 answer
187 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( ...
user avatar
  • 13
2 votes
0 answers
126 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 ...
user avatar
  • 329
2 votes
1 answer
298 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 "...
user avatar
  • 181
1 vote
0 answers
99 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&...
user avatar
1 vote
0 answers
56 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 ...
user avatar
5 votes
1 answer
3k 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 ...
user avatar
  • 1,333
1 vote
1 answer
866 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 ...
user avatar
  • 136
7 votes
2 answers
1k 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 { ...
user avatar
2 votes
1 answer
396 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 ...
user avatar
1 vote
0 answers
20 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 ...
user avatar
  • 171
1 vote
1 answer
1k 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(...
user avatar
  • 1,573
2 votes
0 answers
146 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 ...
user avatar
1 vote
1 answer
630 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 ...
user avatar
8 votes
4 answers
4k 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 ...
user avatar
3 votes
1 answer
376 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 ...
user avatar
7 votes
2 answers
2k 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?
user avatar
1 vote
1 answer
166 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 ...
user avatar
5 votes
1 answer
224 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 ...
user avatar
  • 432
115 votes
6 answers
54k 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?
user avatar
  • 78.3k