Making a follow up thread since it was recommended to post the full code snippet: "Out of gas" revert inside the multisend contract

We are still having the issue of the revert inside the multisend contract and have isolated it being caused by the safeTxGas parameter somehow always ending up being 0 (even tried hardcoding to be a nonzero value using some fancy spread operator work and still went to 0).

We have gone over the documentation at https://github.com/gnosis/safe-contracts/blob/a6504a9afdeac186a8cdb29ad68b189523c80eda/docs/safe_tx_gas.md and are seeing unexpected behavior.

This is an example of one of the failed transactions: https://rinkeby.etherscan.io/tx/0x076124dd128c3ce347c8f60c2bf984e505b0b926a95f04fe8de0b5702708dbdb

The docs above mention "That means if safeTxGas is set to 0 the Safe contract sents along all awailable gas when performing the internal Safe transaction." But at https://rinkeby.etherscan.io/tx/0x076124dd128c3ce347c8f60c2bf984e505b0b926a95f04fe8de0b5702708dbdb#internal we can see that instead of forwarding remaining gas the Gas Limit is set to 0 which results in an Out of Gas revert. We see that it is failing because it is out of gas unlike other issues on this forum where someone is trying to send more Ether than they have or something similar.

The full code snippet is posted below:

const { default: EthersSafe, EthersAdapter } = require("@gnosis.pm/safe-core-sdk");
const ethers = require("ethers");

const ERC20Contract = require("../artifacts/@openzeppelin/contracts/token/ERC20/ERC20.sol/ERC20.json");
const erc20Interface = new ethers.utils.Interface(ERC20Contract.abi);

// Address constants
const safeAddress = "0x7328285B4435dbc51897DC2d900D21707d14253e";
const BATERC20Rinkeby = "0xbF7A7169562078c96f0eC1A8aFD6aE50f12e5A99";
const zrxERC20Rinkeby = "0xddea378A6dDC8AfeC82C36E9b0078826bf9e68B6";
const recipient1 = "0x6c25c43856df0fcb79b151c9c2f9a9dcc2eb46be";

async function main() {
  const provider = ethers.getDefaultProvider(process.env.INFURA_RINKEBY_URL);
  const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
  const ethAdapter = new EthersAdapter({ ethers, signer });

  const safeSdk = await EthersSafe.create({
    ethAdapter: ethAdapter,
    safeAddress: safeAddress,

  // Create Transaction
  const multiSendTx = [
      to: zrxERC20Rinkeby,
      data: erc20Interface.encodeFunctionData("transfer", [
      value: "0",
      to: BATERC20Rinkeby,
      data: erc20Interface.encodeFunctionData("transfer", [
      value: "0",
  const txOptions = {
    safeTxGas: 2300,
    baseGas: 112000,
    refundReceiver: signer.address,
    gasPrice: 3500000000
    //gasPrice: 2500000000,
    //gasToken: "0x0000000000000000000000000000000000000000"
  const safeTransaction = await safeSdk.createTransaction(multiSendTx, txOptions);
  // Execute Transaction
  const execOptions = {
    gasLimit: 350000
  //const executeTxResponse = await safeSdk.executeTransaction(safeTransaction, execOptions);
  //const receipt = await executeTxResponse.transactionResponse?.wait();


  .then(() => process.exit(0))
  .catch((error) => {

Thanks for taking a look!


2 Answers 2


In the Rinkeby transaction that you linked, you set a gasPrice for the SafeTransaction.

enter image description here

In this case the gas specified by safeTxGas is sent along to avoid that the relayer can use more gas than expected and therefore increasing the refund. This is mentioned in the section with gas refund of the documentation you linked.

As mentioned in the other question you linked, this seems to be a bug in the sdk, that safeTxGas is not applied in your example.

I would recommending opening an issues on the Safe core sdk.


List itemI just want to share for others that may end up here:

Through trial and error, I've determined that for some reason, Gnosis throws this error+roadblock anytime it predicts the transaction will fail, and it has nothing to do with gas--it's just trying to protect you and refusing to let you try by limiting your gas.

I (for example) am attempting to deploy a contract through my gnosis multisig (on rinkeby, for now). This worked with three example contracts on Friday. With the latest version of the contract initcode, however, it does not.

I assumed it was my fault, that I was using the web interface incorrectly. The only error is that when trying to perform the transaction, I'd see the same error message as this user--"transaction will likely fail", trying to manually add gas, seeing metamask complain, safetxgas being 0. Just could not force it through. Later, using tenderly, I was able to figure out what the actual error was (which had nothing to do with gas).

I wish it gave better error messaging, but if you're seeing this error message, focusing on the gas is probably barking up the wrong tree. Better to troubleshoot your intended transaction.

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.