{"id":27608152,"url":"https://github.com/merklejerk/send-tokens","last_synced_at":"2025-04-22T22:24:17.878Z","repository":{"id":34043364,"uuid":"142219559","full_name":"merklejerk/send-tokens","owner":"merklejerk","description":"Simple CLI tool to send ERC20 tokens with a private key, mnemonic, or keystore.","archived":false,"fork":false,"pushed_at":"2023-01-23T20:53:33.000Z","size":538,"stargazers_count":30,"open_issues_count":8,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T17:38:57.826Z","etag":null,"topics":["airdrop","cli","ens","erc20","es2017","ethereum","private-key","self-signed","send","tokens","transfer","wallet"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/merklejerk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-24T22:36:12.000Z","updated_at":"2024-02-29T12:51:47.000Z","dependencies_parsed_at":"2023-02-13T03:05:37.902Z","dependency_job_id":null,"html_url":"https://github.com/merklejerk/send-tokens","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merklejerk%2Fsend-tokens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merklejerk%2Fsend-tokens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merklejerk%2Fsend-tokens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/merklejerk%2Fsend-tokens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/merklejerk","download_url":"https://codeload.github.com/merklejerk/send-tokens/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250332668,"owners_count":21413247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airdrop","cli","ens","erc20","es2017","ethereum","private-key","self-signed","send","tokens","transfer","wallet"],"created_at":"2025-04-22T22:24:17.360Z","updated_at":"2025-04-22T22:24:17.859Z","avatar_url":"https://github.com/merklejerk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://travis-ci.org/merklejerk/send-tokens.svg?branch=master)](https://travis-ci.org/merklejerk/send-tokens)\n[![npm package](https://badge.fury.io/js/send-tokens.svg)](https://www.npmjs.com/package/send-tokens)\n\n# send-tokens\nA simple CLI tool (and library) for sending Ethereum ERC20 tokens using any of the following:\n\n- A wallet's private key\n- A keystore file\n- An HD wallet mnemonic phrase\n- A provider (node) wallet address\n\nFor the ether version of this package, check out\n[send-ether](https://github.com/merklejerk/send-ether).\n\n\n### Migrating from 1.x:\nToken amounts are now in **whole** units, by default, which is defined by the number\nof decimal places a token contract supports. This means sending `100.123` tokens\nwith a token that supports 18 decimal places, will actually send\n`100.123 * 10^18` of the smallest unit of that token. This behavior can be\noverridden with the `--decimals` option.\n\n### Contents\n\n- [Installation](#installation)\n- [Examples](#examples)\n- [All Options](#all-options)\n- [JSON Logs](#json-logs)\n- [ENS Names](#ens-names)\n- [Library Usage](#library-usage)\n\n## Installation\n```bash\nnpm install -g send-tokens\n# or\nyarn global add send-tokens\n```\n\n## Examples\n```bash\n# Address of token contract. May also be an ENS name.\nTOKEN='0x1658164265555FA310d20bC601Dd32e9b996A436'\n# Recipient of tokens. May also be an ENS name.\nDST='0x0420DC92A955e3e139b52142f32Bd54C6D46c023'\n# Sending wallet's private key.\nPRIVATE_KEY='0x52c251b9e04740157471a724e9a3210b83fac5834b29c89d5bd57661bd2a7057'\n# Sending wallet's HD mnemonic.\nMNEMONIC='butter crepes sugar flour eggs milk ...'\n\n# Send 100.53 WHOLE tokens to an address,\n# on the mainnet, using a wallet's private key\n$ send-tokens --key $PRIVATE_KEY $TOKEN $DST 100.53\n\n# Send 32 of the smallest units of a token to an address, on ropsten,\n# using an HD wallet mnemonic\n$ send-tokens --network ropsten --mnemonic \"$MNEMONIC\" $TOKEN $DST 32 -d 0\n\n# Send 99 WHOLE tokens to an address, on the mainnet,\n# using a keystore file.\n$ send-tokens --keystore './path/to/keystore.json' --password 'secret' $TOKEN $DST 99\n\n# Send 64.3163512 WHOLE tokens to an address, on the provider's network,\n# using the provider's default wallet, and wait for 3 confirmations.\n$ send-tokens --provider 'http://localhost:8545' --confirmations 3 $TOKEN $DST 64.3163512\n```\n\n## All Options\n```\n$ send-tokens --help\nUsage: send-tokens [options] \u003ctoken\u003e \u003cto\u003e \u003camount\u003e\n\nOptions:\n\n  -v, --version               output the version number\n  -d, --decimals \u003cn\u003e          decimal places amount is expressed in (default: max token supports)\n  -k, --key \u003chex\u003e             sending wallet's private key\n  -f, --key-file \u003cfile\u003e       sending wallet's private key file\n  -s, --keystore-file \u003cfile\u003e  sending wallet's keystore file\n  --password \u003cpassword        keystore file password\n  -m, --mnemonic \u003cphrase\u003e     sending wallet's HD wallet phrase\n  --mnemonic-index \u003cn\u003e        sending wallet's HD wallet account index (default: 0)\n  -a, --account \u003chex\u003e         sending wallet's account address (provider wallet)\n  -c, --confirmations \u003cn\u003e     number of confirmations to wait for before returning (default: 0)\n  -p, --provider \u003curi\u003e        provider URI\n  -n, --network \u003cname\u003e        network name\n  -G, --gas-price \u003cgwei\u003e      explicit gas price, in gwei (e.g., 20)\n  -l, --log \u003cfile\u003e            append a JSON log to a file\n  --no-confirm                bypass confirmation\n  -h, --help                  output usage information\n\n```\n\n## JSON Logs\nIf you pass the `--log` option, a JSON object describing the transfer\nwill be appended to a file when the transaction is mined, one object per line.\n\n##### Log Entries\nLog entries follow this structure:\n```js\n{\n   // Unique transfer ID to identify related logs.\n   id: '88fdd8a4b8084c36',\n   // UNIX time.\n   time: 1532471209842,\n   // Address of token contract.\n   token: '0x1658164265555FA310d20bC601Dd32e9b996A436',\n   // Address of sender.\n   from: '0x0420DC92A955e3e139b52142f32Bd54C6D46c023',\n   // Address of recipient.\n   to: '0x2621Ea417659Ad69BAE66AF05eBE5788e533E5e8',\n   // Amount of tokens sent (in weis).\n   amount: '20',\n   // Transaction ID of transfer.\n   txId: '0xd9255f8365305ebffd77cb30d09f82745eaa232e42739f5fc2788fa46f1347e3',\n   // Block number where the transfer was mined.\n   block: 4912040,\n   // Gas used.\n   gas: 40120\n}\n```\n\n## ENS Names\nAnywhere you can pass an address, you can also pass an ENS name, like\n`'ethereum.eth'`, and the it will automatically be resolved to a real\naddress.\n\nENS resolution only works on the mainnet, rinkeby, and ropsten, and the name\nmust be fully registered with the ENS contract and a resolver.\n\n\n## Library Usage\nThe `send-tokens` package can be used as a library through the `sendTokens()`\nfunction.\n\n`sendTokens()` asynchronously resolves to a\n[transaction receipt](https://web3js.readthedocs.io/en/1.0/web3-eth.html#eth-gettransactionreceipt-return)\nonce the transaction has been mined (or confirmed, if the\n`confirmations` option is \u003e 0).\n\n#### sendTokens() Examples\n\n```js\nconst {sendTokens} = require('send-tokens');\n// Address of token contract.\nconst TOKEN_ADDRESS = '0x1658164265555FA310d20bC601Dd32e9b996A436';\n// Recipient of tokens.\nconst RECIPIENT = '0x0420DC92A955e3e139b52142f32Bd54C6D46c023';\n\n// Sending wallet's private key.\nconst PRIVATE_KEY = '0x52c251b9e04740157471a724e9a3210b83fac5834b29c89d5bd57661bd2a7057';\n// Send 100 WHOLE tokens of tokens to someone using a private key and wait for\n// it to be mined.\nlet receipt = await sendTokens(TOKEN_ADDRESS, RECIPIENT, '100',\n  {key: PRIVATE_KEY});\n\n// Sending wallet's mnemonic.\nconst MNEMONIC = 'butter crepes sugar flour eggs milk ...';\n// Send 100.312 WHOLE tokens to someone using a (BIP39) mnemonic phrase\n// and wait for it to be mined and confirmed 3 times.\nreceipt = await sendTokens(TOKEN_ADDRESS, RECIPIENT, '100.312',\n  {mnemonic: MNEMONIC, confirmations: 3});\n\n// Sending wallet's keystore file contents as a string.\nconst KEYSTORE = '{...}';\n// Keystore password.\nconst PASSWORD = 'secret';\n// Send 32 of the smallest unit of tokens to someone using a keystore file,\n// print the transaction ID when it's available, and wait for it to be mined.\nreceipt = await sendTokens(TOKEN_ADDRESS, RECIPIENT, '32', {\n    keystore: KEYSTORE,\n    password: PASSWORD,\n    decimals: 0,\n    onTxId: console.log\n  });\n```\n\n#### Full sendTokens() Options\n\n```js\nconst {sendTokens} = require('send-tokens');\n// Send TOKEN_AMOUNT tokens to RECIPIENT via the token contract at\n// TOKEN_ADDRESS.\n{tx: Object} = async sendTokens(\n  // Address of token contract.\n  // Should be a hex string ('0x...')\n  TOKEN_ADDRESS: String,\n  // Address of recipient.\n  // Should be a hex string ('0x...')\n  RECIPIENT: String,\n  // Amount of tokens to send. Units depend on `decimals` option.\n  // Should be a base-10 decimal string (e.g., '1234.56').\n  TOKEN_AMOUNT: String,\n  // Options object\n  {\n    // Suppress output.\n    quiet: Boolean,\n    // If specified, append to a JSON log file at this path.\n    log: String,\n    // Call this function, passing the transaction hash/ID of the transaction\n    // once it becomes available (transaction is posted to the blockchain but\n    // not yet mined).\n    onTxId: Function,\n    // Decimal places of token amount.\n    // E.g., 18 for 18 decimal places, 0 for smallest units.\n    // Defaults to maximum decimal places supported by token contract.\n    decimals: Number,\n    // If connecting to a custom provider (e.g., a private node), this\n    // can be the set to the address of an unlocked wallet on the provider\n    // from which to send the tokens.\n    account: String,\n    // Hex-encoded 32-byte private key of sender (e.g., '0x1234...').\n    key: String,\n    // BIP39 mnemonic phrase of sender.\n    mnemonic: String,\n    // Sender's Mnemonic account index. Defaults to 0.\n    mnemonicIndex: Number,\n    // Sender's JSON-encoded keystore file contents.\n    keystore: String,\n    // Sender's keystore file path.\n    keystoreFile: String,\n    // Keystore password.\n    password: String,\n    // Ethereum network to use. May be 'main', 'ropsten', 'rinkeby', or 'kovan'.\n    // Defaults to 'main',\n    network: String,\n    // Gas price for the transaction.\n    // Should be a number in gweis.\n    // Defaults to current network gas price.\n    gasPrice: Number,\n    // Number of confirmations to wait for after the transaction is mined.\n    // Maximum of 12. Defaults to 0 (no confirmations).\n    confirmations: Number,\n    // Infura API key to use.\n    infuraKey: String,\n    // Custom provider. May either be a URI (e.g., http://localhost:8545) or\n    // a Provider object from Web3.\n    provider: String | Object,\n    // Custom web3 object.\n    web3: Object\n  });\n```\n\n#### toWallet()\nAnother exposed library function is `toWallet()`, which returns an address\n\u0026 private key pair from a private key, mnemonic, or keystore. Below are the\nfull options.\n\n```js\nconst {toWallet} = require('send-tokens');\n// Convert a private key, mnemonic, or keystore to an address and private-key\n// pair object. Both fields will be a hex-encoded string.\n{address: String, key: String} = toWallet({\n    // Hex-encoded 32-byte private key of sender (e.g., '0x1234...').\n    key: String,\n    // BIP39 mnemonic phrase.\n    mnemonic: String,\n    // Mnemonic account index. Defaults to 0.\n    mnemonicIndex: Number,\n    // JSON-encoded keystore file contents.\n    keystore: String,\n    // Keystore password (if `keystore` is passed).\n    password: String\n  });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerklejerk%2Fsend-tokens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmerklejerk%2Fsend-tokens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmerklejerk%2Fsend-tokens/lists"}