2

Currently I start learning gnosis-safe contracts I have a small doubt in gnosis-proxy contract how to encode initializer in createProxyWithNonce function.

Reference transaction id : https://rinkeby.etherscan.io/tx/0x1a06fa9fa2e420391ceb159ea41eeb595750ed0d88a14be2e154a7df959f46bc

1 Answer 1

3

As proxies canot use the conventional constructor approach, the common way to compensate for this is to provide an initialization function (see OpenZepplin).

To avoid that this can be front-run in a malicious way the Safe proxy factory allows you to specify the initializer and will then also invoke this initializer after the proxy has been deployed.

Therefore the initializer is just the encoded method call to the initializer method (the setup method in case of the Safe contract).

You can find an example for this in the Safe contracts tests.

2
  • Thanks @Richard. I am stuck with the same problem. It is clear to me that the proxies are initialized as usual via an initializing function call that acts like a constructor. However the question remains what is the encoding. Usually for the on-chain encoding I would use abi.encodeWithSignature("setup()", arg1, arg2, ...., argn). From inspection I figured that the last arg is just the encoding of the array of signers. But it is not clear to me what comes before that.
    – Marlo
    Commented Mar 25, 2022 at 14:08
  • 1
    Maybe github.com/gnosis/safe-factories/blob/master/contracts/… can give you some pointers
    – Richard
    Commented Mar 27, 2022 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.