1

An example of the v 1.4.1 Gnosis Safe contract is deployed here: https://etherscan.io/address/0x41675C099F32341bf84BFc5382aF534df5C7461a#code

You can see that the setup function in Safe.sol does not have a return value. A code for the full function is copied below:

function setup(
    address[] calldata _owners,
    uint256 _threshold,
    address to,
    bytes calldata data,
    address fallbackHandler,
    address paymentToken,
    uint256 payment,
    address payable paymentReceiver
) external {
    // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice
    setupOwners(_owners, _threshold);
    if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
    // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
    setupModules(to, data);

    if (payment > 0) {
        // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)
        // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment
        handlePayment(payment, 0, 1, paymentToken, paymentReceiver);
    }
    emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);
}

Some other code in the repo for Safe-Global/protocol-kit here implies that the setup function returns some transaction result data. A snippet of that code is here:

const txResponse = await this.contract.setup(
  owners,
  threshold,
  to,
  data,
  fallbackHandler,
  paymentToken,
  payment,
  paymentReceiver,
  options
)

I'm having trouble understanding where anything is returned though?

3 Answers 3

5

That's not a return data. That's a normal transaction. Whenever we call any contract function that performs write operations, the calls is sent in a form of transaction. Any js library would fetch the transaction details after calling a function. This txResponse contains the blockHash, TxHash, timestamp etc.

2
  • thank you. So basically there is a default return value that just gives you transaction receipt information? So you're saying the return vlaue in solidity is only relevant in solidity world, but that's totally separate from the js return value. thank you.
    – Paul
    Commented Sep 11, 2023 at 16:49
  • yes, correct. In js, that's the so-called transaction receipt. Commented Sep 12, 2023 at 1:49
3

The setup function doesn't include any return function . The code you are checking that is for SDK purposes and return function is used in the SDK code not the contract code

1

As pointed out by @Zartaj Afser, the setup function you are referring to doesn't return any data. This can be verified by looking at the function signature function setup(...) external {} which does not include a returns (see here).

Instead the javascript constant txResponse will contain information about the transaction like transaction hash, confirmation, receipt, etc (reference). This applies when using the popular javascript library Web3.js (which I assume you are using), but other libraries should return a similar structure.

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.