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

feat: batch transfer #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chandrabosep
Copy link

Description: Implemented Batch Transfer Functionality

Added batchTransferCommand function to handle batch transfers.

  • Validates input batch file and wallet existence.
  • Verifies sufficient funds in the wallet before processing each transaction.
  • Handles multiple batch transactions sequentially, ensuring that each transfer meets the wallet balance requirements.
  • Provides user-friendly output messages with transaction status, including successful confirmations and failure cases.
  • Improves error handling for common issues like invalid batch data, insufficient funds, or missing wallet.

Example Usage:

bun run batch --testnet --file ./batch.json

Batch File Format (batch.json):

[
  {
    "to": "0xA9ab8933Ff0467D51d13ea2bFECD81504Fc6f15a",
    "value": 0.000000001
  },
  {
    "to": "0xC0d2F97e6Bec1C04dA1188abA6F006AA4d04EEDC",
    "value": 0.000000002
  }
]

This file contains an array of transactions with recipient addresses (to) and the amounts to transfer (value) in tRBTC.

Short Description:

Implemented a batch transfer command that allows users to send multiple transactions in one batch, ensuring sufficient funds and wallet validation before processing, with clear output and error handling for each transaction.

Example:

Batch File (batch.json):

image

image

image

@ezequiel-rodriguez
Copy link
Collaborator

Hi!
I like what you are trying to do here but in order to be able to merge it, you are required to make some changes:

  • The UX it is not flowing right...
    ** It is not nice for the user to fill in the same password over and over on each transaction. It should be asked once at the beginning.

    ** There should be a way of stopping the batch execution, instead of asking to confirm the execution of each transaction.

  • The way to input the transactions also is not nice because the usage of this CLI doesn't allow the user to create files where it is being used. So my suggestion is that you can ask for the addresses and amounts through the command. Check this options:
    ** cli batch-send --interactive and then ask for the data like:
    Enter address: 0x1234...abcd
    Enter amount: 1.5
    Add another transaction? (y/n): y
    **. Use the json format to echo'd the addresses and amounts and then send it to the command
    echo '{"transactions":[{"address":"0x1234...abcd","amount":1.5},{"address":"0xabcd...1234","amount":2.0}]}' | cli batch-send
    ** Bonus points if you make it work with one of the options + the file you already did

@chandrabosep
Copy link
Author

Thanks for your input, @ezequiel-rodriguez. I'll work on the points you mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants