# Not able to compute address for create2 + minimal proxy implementation

**URL:** <https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075>\
**Category:** Contracts\
**Tags:** proxies\
**Created:** [June 11, 2020, 7:54am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075 "2020-06-11T07:54:28Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thrilok\_kumar](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Thrilok\_kumar](https://forum.openzeppelin.com/u/Thrilok_kumar)\
**Post date:** [June 11, 2020, 7:54am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/1 "2020-06-11T07:54:28Z")

</div>

I was trying create2 + minimal proxy implementation. I was able to deploy a wallet contract using create2 + minimal proxy. But I was not able to compute the address for create2+minimal proxy.

Code snippet to create a clone:

```auto
function createClone(address target, uint256 salt) public returns (address result) {
    bytes20 targetBytes = bytes20(target);
    assembly {
      let clone := mload(0x40)
      mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
      mstore(add(clone, 0x14), targetBytes)
      mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
      result := create2(0, clone, 0x37, salt)
    }
  }
}

```

How to compute address for create2 + minimal proxy? Similar way like this function thats done for create2 [https://github.com/OpenZeppelin/openzeppelin-sdk/blob/de895221ffeb8a99a5314d0b203db2580a2074f7/packages/lib/contracts/upgradeability/ProxyFactory.sol#L47](https://github.com/OpenZeppelin/openzeppelin-sdk/blob/de895221ffeb8a99a5314d0b203db2580a2074f7/packages/lib/contracts/upgradeability/ProxyFactory.sol#L47)

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 12, 2020, 8:37am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/2 "2020-06-12T08:37:22Z")

</div>

Hi @Thrilok_kumar,

I assume that for the deploy of the minimal proxy the salt should be calculated in a similar way as in the `ProxyFactory`:

> <https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contracts/upgradeability/ProxyFactory.sol#L84>

This would give us a deploy function something like:

```auto
    function deployMinimalWithCreate2(
        uint256 _salt,
        address _logic,
        bytes memory _data
    ) public returns (address proxy) {
        bytes32 salt = _getSalt(_salt, msg.sender);

        // Adapted from https://github.com/optionality/clone-factory/blob/32782f82dfc5a00d103a7e61a17a5dedbd1e8e9d/contracts/CloneFactory.sol
        bytes20 targetBytes = bytes20(_logic);
        assembly {
            let clone := mload(0x40)
            mstore(
                clone,
                0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
            )
            mstore(add(clone, 0x14), targetBytes)
            mstore(
                add(clone, 0x28),
                0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
            )
            proxy := create2(0, clone, 0x37, salt)
        }

        emit ProxyCreated(address(proxy));

        if (_data.length > 0) {
            (bool success, ) = proxy.call(_data);
            require(success);
        }
    }

```

We then need an equivalent of `getDeploymentAddress` for our minimal proxy.

> <https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contracts/upgradeability/ProxyFactory.sol#L47>

We need a hash of our minimal proxy code creation equivalent to the following:

> <https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contracts/upgradeability/ProxyFactory.sol#L13>

I don’t know assembly, so haven’t worked out how to put this part together.

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [June 12, 2020, 8:42pm UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/3 "2020-06-12T20:42:27Z")

</div>

Have you seen the `Create2` library included in OpenZeppelin Contracts?

[https://docs.openzeppelin.com/contracts/3.x/api/utils#Create2](https://docs.openzeppelin.com/contracts/3.x/api/utils#Create2)

It gives you code to deploy a contract and to compute the address.

---

<div class="post-metadata">

**Author:** ![Thrilok\_kumar](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Thrilok\_kumar](https://forum.openzeppelin.com/u/Thrilok_kumar)\
**Post date:** [June 13, 2020, 11:37am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/4 "2020-06-13T11:37:22Z")

</div>

Hey @abcoathup, I tried the way you have told me. So, while computing the address, the computed address and the deployed address is not the same.

Here is my code snippet.

> <https://gist.github.com/thrilok209/d9d1ebc15f27a3a1ef1e6358110dd274#file-create2minimalproxy-sol-L33>

---

<div class="post-metadata">

**Author:** ![Thrilok\_kumar](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@Thrilok\_kumar](https://forum.openzeppelin.com/u/Thrilok_kumar)\
**Post date:** [June 13, 2020, 11:41am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/5 "2020-06-13T11:41:16Z")

</div>

Hey @frangio,

`Create2` Library is just a create2 implementation. I am looking for `create2 + minimal proxy` implementation. I was able to deploy using this implementation. but the computed address is not matching with the deployed address.

> **[USDC payment processing in Coinbase Commerce](https://blog.coinbase.com/usdc-payment-processing-in-coinbase-commerce-b1af1c82fb0#89c1)**
>
> A technical deep-dive on how our team engineered non-custodial smart contracts to efficiently process payments on Coinbase Commerce.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 15, 2020, 4:19am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/6 "2020-06-15T04:19:07Z")

</div>

Hi @Thrilok_kumar,

When calculating the deployment address we need to use the creation code for the minimal proxy, not the logic contract that the minimal proxy points to.

Your code snippet appears to use the creation code for the wallet and not the minimal proxy which is why you get a different address: [https://gist.github.com/thrilok209/d9d1ebc15f27a3a1ef1e6358110dd274#file-create2minimalproxy-sol-L9](https://gist.github.com/thrilok209/d9d1ebc15f27a3a1ef1e6358110dd274#file-create2minimalproxy-sol-L9)

If you haven’t already, it is worth having a read through [Deep dive into the Minimal Proxy contract](https://blog.openzeppelin.com/deep-dive-into-the-minimal-proxy-contract/)

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [June 17, 2020, 1:30am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/7 "2020-06-17T01:30:52Z")

</div>

A post was split to a new topic: [Is creation code and byte code the same thing?](https://forum.openzeppelin.com/t/is-creation-code-and-byte-code-the-same-thing/3117)

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [August 20, 2020, 7:45am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/8 "2020-08-20T07:45:39Z")

</div>

Hi @Thrilok_kumar,

I created a simple Minimal Proxy Factory that computes the address for create2 and minimal proxies:

> [@How to compute the CREATE2 address for a minimal proxy?](https://forum.openzeppelin.com/t/how-to-compute-the-create2-address-for-a-minimal-proxy/3595/2):
>
> Hi Ed, I created the following simple Minimal Proxy Factory to compute an address and deploy. I used @tinchoabbate’s excellent deep dive to get the byte code for a minimal proxy: I used OpenZeppelin Contracts [Create2](https://docs.openzeppelin.com/contracts/3.x/api/utils#Create2) to compute the address and to deploy. warning The following code hasn’t been tested nor has it been audited A more complete version would also include initialization of the minimal proxy (e.g. [https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contr…](https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/packages/lib/contracts/upgradeability/ProxyFactory.sol#L32)

---

<div class="post-metadata">

**Author:** ![itxtoledo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/itxtoledo/32/2932_2.png) [@itxtoledo](https://forum.openzeppelin.com/u/itxtoledo)\
**Post date:** [August 30, 2020, 11:01pm UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/9 "2020-08-30T23:01:14Z")

</div>

Did you manage to solve this? I have the same problem and so far no one has managed to find the solution. The javascript function in this tutorial does not return the same address

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [August 30, 2020, 11:50pm UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/10 "2020-08-30T23:50:18Z")

</div>

Hi @itxtoledo,

Welcome to the community forum 👋

Have you tried using the following that I recently put together?: [How to compute the CREATE2 address for a minimal proxy?](https://forum.openzeppelin.com/t/how-to-compute-the-create2-address-for-a-minimal-proxy/3595/2)

---

<div class="post-metadata">

**Author:** ![jimmy](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jimmy](https://forum.openzeppelin.com/u/jimmy)\
**Post date:** [October 6, 2020, 4:42am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/11 "2020-10-06T04:42:12Z")

</div>

Hey @Thrilok_kumar @abcoathup

Re the CREATE2 implementation from Coinbase Commerce in that post. Are Coinbase themselves the contract creator/owners- eg. only they would have the salt for the computed addresses?

Thanks,  
J

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [October 8, 2020, 5:40am UTC](https://forum.openzeppelin.com/t/not-able-to-compute-address-for-create2-minimal-proxy-implementation/3075/12 "2020-10-08T05:40:42Z")

</div>

Hi @jimmy,

Welcome to the community 👋

I haven’t looked at their implementation other than the contract example given in the article. Anyone calling the factory could provide a salt (as long as it was unique).
