How to encode initializer in gnosis-safe proxy contract?

306 Views Asked by At

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

There are 1 best solutions below

0
On

This is how I am doing it in Typescript.

import { Contract } from 'web3-eth-contract';
import { SafeAccountConfig } from '@gnosis.pm/safe-core-sdk';
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
const getInitilizer = (
  safeProxyContract: Contract,
  methodName: string,
  {
    owners,
    threshold,
    to = ZERO_ADDRESS,
    data = '0x',
    fallbackHandler = ZERO_ADDRESS,
    paymentToken = ZERO_ADDRESS,
    payment = 0,
    paymentReceiver = ZERO_ADDRESS,
  }: SafeAccountConfig
) => {
  return safeProxyContract.methods[methodName](
    owners,
    threshold,
    to,
    data,
    fallbackHandler,
    paymentToken,
    payment,
    paymentReceiver
  ).encodeABI();
};

Usage:

getInitilizer(<SafeProxyContractInstance>, 'setup', <SafeAccountConfig>);