I'm trying to create a safe and withdraw interacting with the smart contract. I managed to create a new safe but when I try to call the execTransaction function I'm having some issues.

// SPDX-License-Identifier: MIT
pragma solidity >0.6.0;

import "./GnosisSafeProxyFactory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./GnosisSafe.sol";

interface GnosisSafeSetup {
    function setup(
        address[] calldata _owners,
        uint256 _threshold,
        address to,
        bytes calldata data,
        address fallbackHandler,
        address paymentToken,
        uint256 payment,
        address payable paymentReceiver
    ) external;

contract CreateSafe {

    GnosisSafeProxyFactory private constant factory = GnosisSafeProxyFactory(0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2);
    GnosisSafeProxy public proxy;

    address singleton = 0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552;
    address fallbackHandler = 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4;
    address paymentReceiver = 0xe92Abac47DF8E48E5E60d5Ec9e348E9580191C93;
    function createNewSafe() public {
        address[] memory owners = new address[](1);
        owners[0] = msg.sender;
        bytes memory proxyInitData = abi.encodeWithSelector(
            1, // threshold
            address(0x0), // to
            new bytes(0), // data
            address(0x0), // paymentToken
            0, // payment

        // safe address        
        proxy = factory.createProxyWithNonce(singleton, proxyInitData, block.timestamp);

    function withdrawETH(address payable safeAddress, uint256 _value) public {
        // TODO require balance > _value
        GnosisSafe safe = GnosisSafe(safeAddress);

        safe.execTransaction{value: _value}(
            msg.sender, // to
            new bytes(0), // data
            0, // operation
            0, // safeTxGas
            0, // baseGas
            0, // gasPrice
            address(0), // gasToken
            payable(msg.sender), // refundReceiver
            "SIGNATURE" // copied from old transaction

TypeError: Invalid type for argument in function call. Invalid implicit conversion from int_const 0 to enum Enum.Operation requested.

All the examples I was seeing were using 0 and I was looking at a transaction where I withdrawed ETH from the safe and the value is 0 too.. Also does anyone know how to get the signature hash?

1 Answer 1


You need to use the Enum.Operation when using Solidity. 0 is used for Javascript examples.

Regarding signatures: https://docs.gnosis-safe.io/contracts/signatures

  • Nice, please then mark the question as solved ;)
    – Uxío
    Apr 7, 2022 at 12:22

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.