Skip to content

A simple CLI for making a bulk STX transfer in one command.

License

Notifications You must be signed in to change notification settings

stacks-network/send-many-stx-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@stacks/send-many-stx-cli

A simple CLI for making a bulk STX transfer in one command.

It uses a Clarity contract to enable transfering STX to multiple recipients in one transaction.

Default contracts used:

Testnet: https://explorer.stacks.co/txid/STR8P3RD1EHA8AA37ERSSSZSWKS9T2GYQFGXNA4C.send-many?chain=testnet

Mainnet: https://explorer.stacks.co/txid/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many?chain=mainnet

Usage

$ npm install -g @stacks/send-many-stx-cli
$ stx-bulk-transfer COMMAND
running command...
$ stx-bulk-transfer (-v|--version|version)
@stacks/send-many-stx-cli/1.4.0 darwin-arm64 node-v15.14.0
$ stx-bulk-transfer --help [COMMAND]
USAGE
  $ stx-bulk-transfer COMMAND
...

Commands

stx-bulk-transfer deploy-contract [CONTRACT]

Deploy send-many, send-many-memo, memo-expected.

USAGE
  $ stx-bulk-transfer deploy-contract [CONTRACT]

ARGUMENTS
  CONTRACT  The contract to deploy

OPTIONS
  -b, --broadcast                        Whether to broadcast this transaction. Omitting this flag will not broadcast
                                         the transaction.

  -h, --help                             show CLI help

  -k, --privateKey=privateKey            (required) Your private key

  -n, --network=mocknet|testnet|mainnet  [default: testnet] Which network to broadcast this to

  -q, --quiet                            Reduce logging from this command. If this flag is passed with the broadcast
                                         (-b) flag,
                                         only the transaction ID will be logged. If the quiet flagged is passed without
                                         broadcast,
                                         only the raw transaction hex will be logged.

  -u, --nodeUrl=nodeUrl                  A default node URL will be used based on the `network` option. Use this flag to
                                         manually override.

  --nonce=nonce                          Optionally specify a nonce for this transaction

DESCRIPTION
  A utility to simplify deploying contracts related to the STX bulk transfer tool. It deploys
     the contract on the address of the provided private key.

     Valid choices are: send-many, send-many-memo, and memo-expected.

     The memo-expected contract is an empty contract that is checked by the `send-many-memo-safe`
     command. If a contract called 'memo-expected' is deployed on a principal, and no memo is passed,
     the send-many will be aborted before it reaches the chain.

     Example usage:

     ```
     npx stx-bulk-transfer deploy-contract memo-expected -k my_private_key -n testnet -b
     ```

See code: dist/commands/deploy-contract.ts

stx-bulk-transfer send-many [RECIPIENTS]

Execute a bulk STX transfer.

USAGE
  $ stx-bulk-transfer send-many [RECIPIENTS]

ARGUMENTS
  RECIPIENTS  A set of recipients in the format of "address,amount_ustx"
              Example: STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100 ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50

OPTIONS
  -a, --allowSingleStxTransfer           If enabled and only a single recipient is specified, a STX-transfer transaction
                                         type will be used rather than a contract-call transaction.
                                         If omitted, a contract-call will always be used, which can be less efficient.

  -b, --broadcast                        Whether to broadcast this transaction. Omitting this flag will not broadcast
                                         the transaction.

  -c, --contractAddress=contractAddress  Manually specify the contract address for send-many. If omitted, default
                                         contracts will be used.

  -h, --help                             show CLI help

  -k, --privateKey=privateKey            (required) Your private key

  -m, --feeMultiplier=feeMultiplier      Optionally specify a fee multiplier. If passed, the tx fee will be (estimated
                                         fee + (estimated fee * multiplier)).
                                         For example, a fee multiplier of 15 for a tx with an estimated fee of 200 would
                                         result in a tx with the fee of 230.

  -n, --network=mocknet|testnet|mainnet  [default: testnet] Which network to broadcast this to

  -q, --quiet                            Reduce logging from this command. If this flag is passed with the broadcast
                                         (-b) flag,
                                         only the transaction ID will be logged. If the quiet flagged is passed without
                                         broadcast,
                                         only the raw transaction hex will be logged.

  -u, --nodeUrl=nodeUrl                  A default node URL will be used based on the `network` option. Use this flag to
                                         manually override.

  --nonce=nonce                          Optionally specify a nonce for this transaction

DESCRIPTION
  The bulk transfer is executed in a single transaction by invoking a `contract-call` on the "send-many" contract.

     The default contracts can be found below:

     Testnet: https://explorer.stacks.co/txid/ST3F1X4QGV2SM8XD96X45M6RTQXKA1PZJZZCQAB4B.send-many?chain=testnet
     Mainnet: https://explorer.stacks.co/txid/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many?chain=mainnet

     Example usage:

     ```
     npx stx-bulk-transfer send-many STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100 
  ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50 -k my_private_key -n testnet -b
     ```

See code: dist/commands/send-many.ts

stx-bulk-transfer send-many-memo [RECIPIENTS]

Execute a bulk STX transfer, with memos attached.

USAGE
  $ stx-bulk-transfer send-many-memo [RECIPIENTS]

ARGUMENTS
  RECIPIENTS  A set of recipients in the format of "address,amount_ustx,memo". Memo is optional.
              Example: STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100,memo ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50

OPTIONS
  -a, --allowSingleStxTransfer           If enabled and only a single recipient is specified, a STX-transfer transaction
                                         type will be used rather than a contract-call transaction.
                                         If omitted, a contract-call will always be used, which can be less efficient.

  -b, --broadcast                        Whether to broadcast this transaction. Omitting this flag will not broadcast
                                         the transaction.

  -c, --contractAddress=contractAddress  Manually specify the contract address for send-many-memo. If omitted, default
                                         contracts will be used.

  -h, --help                             show CLI help

  -j, --jsonOutput                       Output data in JSON format

  -k, --privateKey=privateKey            (required) Your private key

  -m, --feeMultiplier=feeMultiplier      Optionally specify a fee multiplier. If passed, the tx fee will be (estimated
                                         fee + (estimated fee * multiplier)).
                                         For example, a fee multiplier of 15 for a tx with an estimated fee of 200 would
                                         result in a tx with the fee of 230.

  -n, --network=mocknet|testnet|mainnet  [default: testnet] Which network to broadcast this to

  -q, --quiet                            Reduce logging from this command. If this flag is passed with the broadcast
                                         (-b) flag,
                                         only the transaction ID will be logged. If the quiet flagged is passed without
                                         broadcast,
                                         only the raw transaction hex will be logged.

  -u, --nodeUrl=nodeUrl                  A default node URL will be used based on the `network` option. Use this flag to
                                         manually override.

  --nonce=nonce                          Optionally specify a nonce for this transaction

DESCRIPTION
  The bulk transfer is executed in a single transaction by invoking a `contract-call` on the "send-many-memo" contract.

     The default contracts can be found below:

     Testnet: https://explorer.stacks.co/txid/ST3F1X4QGV2SM8XD96X45M6RTQXKA1PZJZZCQAB4B.send-many-memo?chain=testnet
     Mainnet: https://explorer.stacks.co/txid/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many-memo?chain=mainnet

     Example usage:

     ```
     npx stx-bulk-transfer send-many-memo STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100,hello 
  ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50,memo2 -k my_private_key -n testnet -b
     ```

See code: dist/commands/send-many-memo.ts

stx-bulk-transfer send-many-memo-safe [RECIPIENTS]

Execute a bulk STX transfer, with memos attached, checking if the transfer is safe to send.

USAGE
  $ stx-bulk-transfer send-many-memo-safe [RECIPIENTS]

ARGUMENTS
  RECIPIENTS  A set of recipients in the format of "address,amount_ustx,memo". Memo is optional.
              Example: STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100,memo ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50

OPTIONS
  -a, --allowSingleStxTransfer           If enabled and only a single recipient is specified, a STX-transfer transaction
                                         type will be used rather than a contract-call transaction.
                                         If omitted, a contract-call will always be used, which can be less efficient.

  -b, --broadcast                        Whether to broadcast this transaction. Omitting this flag will not broadcast
                                         the transaction.

  -c, --contractAddress=contractAddress  Manually specify the contract address for send-many-memo. If omitted, default
                                         contracts will be used.

  -h, --help                             show CLI help

  -j, --jsonOutput                       Output data in JSON format

  -k, --privateKey=privateKey            (required) Your private key

  -m, --feeMultiplier=feeMultiplier      Optionally specify a fee multiplier. If passed, the tx fee will be (estimated
                                         fee + (estimated fee * multiplier)).
                                         For example, a fee multiplier of 15 for a tx with an estimated fee of 200 would
                                         result in a tx with the fee of 230.

  -n, --network=mocknet|testnet|mainnet  [default: testnet] Which network to broadcast this to

  -q, --quiet                            Reduce logging from this command. If this flag is passed with the broadcast
                                         (-b) flag,
                                         only the transaction ID will be logged. If the quiet flagged is passed without
                                         broadcast,
                                         only the raw transaction hex will be logged.

  -u, --nodeUrl=nodeUrl                  A default node URL will be used based on the `network` option. Use this flag to
                                         manually override.

  --nonce=nonce                          Optionally specify a nonce for this transaction

DESCRIPTION
  The bulk transfer is executed in a single transaction by invoking a `contract-call` on the "send-many-memo" contract.

     The 'safe' counterpart of send-many-memo checks for the existence of a `memo-expected` contract for each recipient.
     If it exists, the transfer will be aborted if the corresponding memo is empty or missing. A utility command to 
  deploy
     this contract is part of this tool: stx-bulk-transfer deploy-contract memo-expected.

     The default contracts can be found below:

     Testnet: https://explorer.stacks.co/txid/ST3F1X4QGV2SM8XD96X45M6RTQXKA1PZJZZCQAB4B.send-many-memo?chain=testnet
     Mainnet: https://explorer.stacks.co/txid/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.send-many-memo?chain=mainnet

     Example usage:

     ```
     npx stx-bulk-transfer send-many-memo-safe STADMRP577SC3MCNP7T3PRSTZBJ75FJ59JGABZTW,100,hello 
  ST2WPFYAW85A0YK9ACJR8JGWPM19VWYF90J8P5ZTH,50,memo2 -k my_private_key -n testnet -b
     ```

See code: dist/commands/send-many-memo-safe.ts

stx-bulk-transfer validate-address [ADDRESS]

Validates whether the input is a valid STX address for the provided network.

USAGE
  $ stx-bulk-transfer validate-address [ADDRESS]

ARGUMENTS
  ADDRESS  The address to validate

OPTIONS
  -h, --help                             show CLI help
  -n, --network=mocknet|testnet|mainnet  [default: mainnet] Which network to check for
  -v, --verbose                          Print error information for invalid addresses

DESCRIPTION
  Example usage:

     ```
     npx stx-bulk-transfer validate-address SP000000000000000000002Q6VF78 -n mainnet
     ```

See code: dist/commands/validate-address.ts

Development

To run the CLI:

yarn start ARGS_AND_FLAGS

This package uses @vercel/ncc to package the CLI into a single file. yarn build will also automatically update this README.

yarn build

To run the executable:

./bin/run ARGS_AND_FLAGS

About

A simple CLI for making a bulk STX transfer in one command.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •