How to create a batch tx as shown in the safe app where using the click of Execute Batch you can combine all the pending tx into one and execute them at once.

I am using this code:

const executeBatch = async() =>
    var safeTransactionData = [];
    pendingTx.forEach(element => {
      var obj = {
        to: element['to'],
        data: (element['data']==null ? '0x': element['data']),
        value: element['value'],
        nonce: element['nonce']
    const callsOnly = true;
    const safeSdk = await Safe.create(safeConfig);

    const safeTransaction = await safeSdk.createTransaction({safeTransactionData,callsOnly});
    const executeTxResponse = await safeSdk.executeTransaction(safeTransaction);
    const receipt = await executeTxResponse.transactionResponse?.wait();

    console.log('Transaction executed:');

This combines all the tx data into one and executes one tx but the other pending tx remains there and doesn't get executed.

1 Answer 1


My Idea: The external account sends a transaction to the contract, and the contract executes the batch 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.