Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Batch Transfer (ThirdWeb React v5) #5984

Open
emin-karadag opened this issue Jan 18, 2025 · 4 comments
Open

About Batch Transfer (ThirdWeb React v5) #5984

emin-karadag opened this issue Jan 18, 2025 · 4 comments
Assignees
Labels

Comments

@emin-karadag
Copy link

Hello,
How can I send to multiple addresses using <TransactionButton/>?
I made sending to a single wallet as follows.

Link: https://portal.thirdweb.com/react/v5/components/TransactionButton

<TransactionButton
        transaction={async () => {
          if (!account)
            return;

          const transaction = transfer({
            contract,
            to: "0x613540d63666C26593Fce4694d10f7d5de76bdEd",
            amount: 0.1,
          });

          var result = await sendTransaction({ transaction, account });
        }}
        onClick={() => alert("Transaction is about to be sent")}
        onTransactionSent={(result) => {
          console.log("Transaction submitted", result);
        }}
        onTransactionConfirmed={(receipt) => {
          console.log("Transaction confirmed", receipt);
        }}
        onError={(error) => {
          console.log("Transaction error", error);
        }}
      >
        Confirm Transaction
</TransactionButton>

But can you show me an example of how I can do “Batch Transfer”? Unfortunately, the “Batch Transfer” examples in the Thirdweb document were not enough.

Thank you in advance.

Copy link

linear bot commented Jan 18, 2025

@thirdweb-dev thirdweb-dev deleted a comment Jan 20, 2025
@gregfromstl
Copy link
Member

Hey @emin-karadag,

The transaction button is not meant to send batch transactions, but rather a single transaction at a time. If you'd like to send batch transactions with a smart account, you'll need to create the button yourself and follow the example here.

I also noticed your TransactionButton example is wrong. The transaction prop function should return a transaction object, rather than sending the transaction itself.

@gregfromstl gregfromstl self-assigned this Jan 20, 2025
@emin-karadag
Copy link
Author

Hello @gregfromstl ,
First of all, thank you for your answers.

  1. What is the ‘spender’ parameter in the link you sent for Batch Transfer? I guess it is an external smart contract that I need to create on Thirdweb.

  2. Thank you for the misuse in the TransactionButton example. However, I realised that when I return the transaction object, the onError probe works even if the transaction is successful. It happens this way for every successful transaction. But I realised that I didn't get an error when I didn't return anything.
    Translated with DeepL.com (free version)

@gregfromstl
Copy link
Member

You don't need to deploy your own smart contract to use smart accounts. The spender would normally be the address of the smart account that will send the transaction. See the docs here for more info on using AA with React.

Could you share the error it returns and an example transaction? Are you sure the transaction succeeds?

@gregfromstl gregfromstl removed their assignment Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants