├── .github └── workflows │ ├── main.yml │ └── pull-request.yml ├── .gitignore ├── LICENSE.txt ├── README.md ├── package-lock.json ├── package.json ├── src ├── command.ts ├── helper.ts └── index.ts ├── tsconfig.json └── tslint.json /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: 🏗️ Install and build 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - uses: actions/setup-node@v2 14 | with: 15 | node-version: '14' 16 | 17 | - run: yarn install 18 | 19 | - run: yarn build 20 | 21 | publish: 22 | name: 📦 Publish package 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@v2 26 | 27 | - uses: actions/setup-node@v2 28 | with: 29 | node-version: '14' 30 | registry-url: 'https://registry.npmjs.org' 31 | - run: yarn install 32 | 33 | - run: yarn build 34 | 35 | - run: yarn publish --access public 36 | env: 37 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: Pull request 2 | on: 3 | pull_request: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: 🏗️ Install and build 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - uses: actions/setup-node@v2 14 | with: 15 | node-version: '14' 16 | 17 | - run: yarn install 18 | 19 | - run: yarn build -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | .env 6 | 7 | # Logs 8 | logs 9 | *.log 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | lerna-debug.log* 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Tatum Blockchain Services s.r.o. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tatum CLI 2 | Tatum CLI - Command Line Interface to communicate with blockchains. 3 | 4 | ## Installation 5 | Tatum CLI is shipped via npm. It installs a set of CLI commands to generate wallets / private keys securely locally and to communicate with number of blockchains via Tatum API. 6 | NodeJS >=14 is required. 7 | ```bash 8 | npm i -g @tatumio/tatum-cli 9 | ``` 10 | 11 | ## Usage 12 | To see list of all available commands, please see help. 13 | 14 | ```bash 15 | tatum --help 16 | ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@tatumio/tatum-cli", 3 | "version": "1.1.11", 4 | "description": "Tatum CLI - Command Line Interface to communicate with blockchain.", 5 | "main": "dist/index.js", 6 | "engines": { 7 | "node": ">=14" 8 | }, 9 | "scripts": { 10 | "prepublish": "rimraf dist && tsc", 11 | "build": "tsc" 12 | }, 13 | "files": [ 14 | "dist/" 15 | ], 16 | "bin": { 17 | "tatum": "dist/index.js" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/tatumio/tatum-cli.git" 22 | }, 23 | "keywords": [ 24 | "Tatum", 25 | "Tatum CLI", 26 | "CLI", 27 | "Blockchain", 28 | "Security" 29 | ], 30 | "author": "Tatum, hello@tatum.io", 31 | "license": "MIT", 32 | "bugs": { 33 | "url": "https://github.com/tatumio/tatum-cli/issues" 34 | }, 35 | "homepage": "https://github.com/tatumio/tatum-cli#readme", 36 | "dependencies": { 37 | "@tatumio/tatum": "^1.21.9", 38 | "meow": "^7.1.1", 39 | "readline-sync": "^1.4.10", 40 | "reflect-metadata": "^0.1.13", 41 | "split": "^1.0.1" 42 | }, 43 | "devDependencies": { 44 | "rimraf": "^3.0.2", 45 | "tslint": "^6.1.2", 46 | "typescript": "^4.3.2" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/command.ts: -------------------------------------------------------------------------------- 1 | export enum Command { 2 | CREATE = 'create', 3 | CURRENT = 'current', 4 | ERC20 = 'erc20', 5 | NFT = 'nft', 6 | MULTITOKEN = 'multitoken', 7 | GET = 'get', 8 | CONTRACTADDRESS = 'contractaddress', 9 | BEP20 = 'bep20', 10 | URI = 'uri', 11 | ROYALTY = 'royalty', 12 | COUNT = 'count', 13 | DEPLOY = 'deploy', 14 | STORE = 'store', 15 | FEE = 'fee', 16 | DATA = 'data', 17 | UTXO = 'utxo', 18 | BROADCAST = 'broadcast', 19 | HASH = 'hash', 20 | ADDRESS = 'address', 21 | UPDATE = 'update', 22 | DETAIL = 'detail', 23 | LIST = 'list', 24 | WITHDRAWAL = 'withdrawal', 25 | COMPLETE = 'complete', 26 | CANCEL = 'cancel', 27 | BALANCE = 'balance', 28 | EXIST = 'exist', 29 | DELETE = 'delete', 30 | ASSIGN = 'assign', 31 | BLOCK = 'block', 32 | UNBLOCK = 'unblock', 33 | FREEZE = 'freeze', 34 | UNFREEZE = 'unfreeze', 35 | ACTIVATE = 'activate', 36 | DEACTIVATE = 'deactivate', 37 | ENABLE = 'enable', 38 | DISABLE = 'disable', 39 | WALLET = 'wallet', 40 | LEDGER = 'ledger', 41 | ACCOUNT = 'account', 42 | TRANSACTION = 'transaction', 43 | VC = 'vc', 44 | MINT = 'mint', 45 | MINTBATCH = 'mintbatch', 46 | BURNBATCH = 'burnbatch', 47 | TRANSFERBATCH = 'transferbatch', 48 | IPFS = 'ipfs', 49 | XDC = 'xdc', 50 | GAS = 'gas', 51 | BALANCEBATCH = 'balancebatch', 52 | METADATA = 'metadata', 53 | BURN = 'burn', 54 | TRANSFER = 'transfer', 55 | REVOKE = 'revoke', 56 | CUSTOMER = 'customer', 57 | OFFCHAIN = 'offchain', 58 | BITCOIN = 'bitcoin', 59 | CELO = 'celo', 60 | ONE = 'one', 61 | SCRYPTA = 'scrypta', 62 | DOGECOIN = 'dogecoin', 63 | LITECOIN = 'litecoin', 64 | ETHEREUM = 'ethereum', 65 | VECHAIN = 'vechain', 66 | BSC = 'bsc', 67 | ADA = 'ada', 68 | QTUM = 'qtum', 69 | MATIC = 'matic', 70 | XRP = 'xrp', 71 | XLM = 'stellar', 72 | BCH = 'bcash', 73 | BNB = 'binance', 74 | NEO = 'neo', 75 | PRIVATE_KEY = 'privatekey', 76 | } -------------------------------------------------------------------------------- /src/helper.ts: -------------------------------------------------------------------------------- 1 | export const helpMessage = ` 2 | 3 | Usage: tatum command ...list of parameters [--apiKey] 4 | 5 | Tatum CLI - Command Line Interface to communicate with blockchains. 6 | Every JSON request body must be stringified (https://onlinetexttools.com/json-stringify-text), must not contain spaces and should be enclosed in double quotes / apostrophes, based on the OS. 7 | Example command: tatum data create true "{\"data\":\"test data\",\"chain\":\"ETH\"}" 8 | 9 | Commands 10 | 11 | ## blockchain wallet operations, only run locally 12 | wallet create [mnemonic] Generate wallet for a specific blockchain. 13 | wallet privatekey create Generate private key for given derivation index from mnemonic. 14 | wallet address create Generate address for given derivation index from xpub. 15 | 16 | ## store and obtain data from blockchain, API key is required 17 | data create [from] [to] Read data from STDIN and store it to the blockchain: 18 | 1. Ethereum blockchain chosen by the API Key - testnet or mainnet 19 | 2. Quorum - from and to addresses must be present in the command 20 | 3. Matic - testnet is required before the body (data create matic testnet ) 21 | data detail https://tatum.io/apidoc#operation/GetLog 22 | ## IPFS blockchain operations, API key is required 23 | ipfs store https://tatum.io/apidoc#operation/StoreIPFS 24 | ipfs get https://tatum.io/apidoc#operation/GetIPFSData 25 | ipfs delete https://tatum.io/apidoc#operation/DeleteIPFSData 26 | ## Bitcoin blockchain operations, API key is required 27 | bitcoin block current https://tatum.io/apidoc#operation/BtcGetBlockChainInfo 28 | bitcoin block hash https://tatum.io/apidoc#operation/BtcGetBlockHash 29 | bitcoin block detail https://tatum.io/apidoc#operation/BtcGetBlock 30 | bitcoin transaction detail https://tatum.io/apidoc#operation/BtcGetRawTransaction 31 | bitcoin transaction address
https://tatum.io/apidoc#operation/BtcGetTxByAddress 32 | bitcoin transaction utxo https://tatum.io/apidoc#operation/BtcGetUTXO 33 | bitcoin transaction broadcast https://tatum.io/apidoc#operation/BtcBroadcast 34 | bitcoin transaction create https://tatum.io/apidoc#operation/BtcTransferBlockchain 35 | ## Ada blockchain operations, API key is required 36 | ada block current https://tatum.io/apidoc#operation/AdaGetBlockChainInfo 37 | ada block detail https://tatum.io/apidoc#operation/AdaGetBlock 38 | ada transaction detail https://tatum.io/apidoc#operation/AdaGetRawTransaction 39 | ada transaction address
https://tatum.io/apidoc#operation/AdaGetTxByAddress 40 | ada transaction utxo https://tatum.io/apidoc#operation/AdaGetTxByAddress 41 | ada transaction broadcast https://tatum.io/apidoc#operation/AdaBroadcast 42 | ada transaction create https://tatum.io/apidoc#operation/AdaTransferBlockchain 43 | ## Qtum blockchain operations, API key is required 44 | qtum block current https://tatum.io/apidoc#operation/QtumGetCurrentBlock 45 | qtum block detail https://tatum.io/apidoc#operation/AdaGetBlock 46 | qtum transaction detail https://tatum.io/apidoc#operation/QtumGetBlock 47 | qtum transaction address
https://tatum.io/apidoc#operation/GetQtumPaginatedTransaction 48 | qtum transaction utxo https://tatum.io/apidoc#operation/GetQtumUTXOs 49 | qtum transaction broadcast https://tatum.io/apidoc#operation/QtumBroadcast 50 | 51 | ## Dogecoin blockchain operations, API key is required 52 | dogecoin block current https://tatum.io/apidoc#operation/DogeGetBlockChainInfo 53 | dogecoin block hash https://tatum.io/apidoc#operation/DogeGetBlockHash 54 | dogecoin block detail https://tatum.io/apidoc#operation/DogeGetBlock 55 | dogecoin transaction detail https://tatum.io/apidoc#operation/DogeGetRawTransaction 56 | dogecoin transaction utxo https://tatum.io/apidoc#operation/DogeGetUTXO 57 | dogecoin transaction broadcast https://tatum.io/apidoc#operation/DogeBroadcast 58 | dogecoin transaction create https://tatum.io/apidoc#operation/DogeTransferBlockchain 59 | 60 | ## Scrypta blockchain operations, API key is required 61 | scrypta block current https://tatum.io/apidoc#operation/DogeGetBlockChainInfo 62 | scrypta block hash https://tatum.io/apidoc#operation/DogeGetBlockHash 63 | scrypta block detail https://tatum.io/apidoc#operation/DogeGetBlock 64 | scrypta transaction detail https://tatum.io/apidoc#operation/DogeGetRawTransaction 65 | scrypta transaction utxo https://tatum.io/apidoc#operation/DogeGetUTXO 66 | scrypta transaction broadcast https://tatum.io/apidoc#operation/DogeBroadcast 67 | scrypta transaction create https://tatum.io/apidoc#operation/DogeTransferBlockchain 68 | 69 | ## XDC blockchain operations, API key is required 70 | xdc block current https://tatum.io/apidoc#operation/XdcGetCurrentBlock 71 | xdc block detail https://tatum.io/apidoc#operation/XdcGetBlock 72 | xdc account balance xdc
https://tatum.io/apidoc#operation/XdcGetBalance 73 | xdc account balance erc20
74 | xdc transaction detail https://tatum.io/apidoc#operation/XdcGetTransaction 75 | xdc transaction count
76 | xdc transaction broadcast https://tatum.io/apidoc#operation/XdcBroadcast 77 | xdc transaction gas https://tatum.io/apidoc#operation/XdcEstimateGas 78 | xdc transaction create xdc https://tatum.io/apidoc#operation/XdcBlockchainTransfer 79 | xdc transaction create erc20 80 | 81 | ## Ethereum blockchain operations, API key is required 82 | ethereum block current https://tatum.io/apidoc#operation/EthGetCurrentBlock 83 | ethereum block detail https://tatum.io/apidoc#operation/EthGetBlock 84 | ethereum account balance ethereum
https://tatum.io/apidoc#operation/EthGetBalance 85 | ethereum account balance erc20
https://tatum.io/apidoc#operation/EthErc20GetBalance 86 | ethereum transaction detail https://tatum.io/apidoc#operation/EthGetTransaction 87 | ethereum transaction count
https://tatum.io/apidoc#operation/EthGetTransactionCount 88 | ethereum transaction address
https://tatum.io/apidoc#operation/EthGetTransactionByAddress 89 | ethereum transaction broadcast https://tatum.io/apidoc#operation/EthBroadcast 90 | ethereum transaction create ethereum https://tatum.io/apidoc#operation/EthBlockchainTransfer 91 | ethereum transaction create erc20 https://tatum.io/apidoc#operation/EthBlockchainTransferErc20 92 | ethereum transaction deploy erc20 https://tatum.io/apidoc#operation/EthDeployErc20Blockchain 93 | 94 | ## Celo blockchain operations, API key is required 95 | celo block current https://tatum.io/apidoc#operation/CeloGetCurrentBlock 96 | celo block detail https://tatum.io/apidoc#operation/CeloGetBlock 97 | celo account
https://tatum.io/apidoc#operation/CeloGetBalance 98 | celo transaction detail https://tatum.io/apidoc#operation/CeloGetTransaction 99 | celo transaction count
https://tatum.io/apidoc#operation/CeloGetTransactionCount 100 | celo transaction broadcast https://tatum.io/apidoc#operation/CeloBroadcast 101 | celo transaction create https://tatum.io/apidoc#operation/CeloBlockchainTransfer 102 | celo transaction deploy 103 | 104 | ## Harmony/One blockchain operations, API key is required 105 | one block current https://tatum.io/apidoc#operation/OneGetCurrentBlock 106 | one block detail https://tatum.io/apidoc#operation/OneGetBlock 107 | one account
https://tatum.io/apidoc#operation/OneGetBalance 108 | one transaction detail https://tatum.io/apidoc#operation/OneGetTransaction 109 | one transaction count
https://tatum.io/apidoc#operation/OneGetTransactionCount 110 | one transaction broadcast https://tatum.io/apidoc#operation/OneBroadcast 111 | one transaction create https://tatum.io/apidoc#operation/OneBlockchainTransfer 112 | one transaction deploy 113 | 114 | ## BSC blockchain operations, API key is required 115 | bsc block current https://tatum.io/apidoc#operation/BscGetCurrentBlock 116 | bsc block detail https://tatum.io/apidoc#operation/BscGetBlock 117 | bsc account bsc
https://tatum.io/apidoc#operation/BscGetBalance 118 | bsc account bep20
https://tatum.io/apidoc#operation/BscBep20GetBalance 119 | bsc transaction detail https://tatum.io/apidoc#operation/BscGetTransaction 120 | bsc transaction count
https://tatum.io/apidoc#operation/BscGetTransactionCount 121 | bsc transaction broadcast https://tatum.io/apidoc#operation/BscBroadcast 122 | bsc transaction create bsc https://tatum.io/apidoc#operation/BscBlockchainTransfer 123 | bsc transaction create bep20 https://tatum.io/apidoc#operation/BscBlockchainTransferBep20 124 | bsc transaction deploy https://tatum.io/apidoc#operation/BscDeployBep20Blockchain 125 | 126 | ## Polygon/Matic blockchain operations, API key is required 127 | matic block current https://tatum.io/apidoc#operation/PolygonGetCurrentBlock 128 | matic block detail https://tatum.io/apidoc#operation/PolygonGetBlock 129 | matic account
https://tatum.io/apidoc#operation/PolygonGetBalance 130 | matic transaction detail https://tatum.io/apidoc#operation/PolygonGetTransaction 131 | matic transaction count
https://tatum.io/apidoc#operation/PolygonGetTransactionCount 132 | matic transaction broadcast https://tatum.io/apidoc#operation/PolygonBroadcast 133 | matic transaction create https://tatum.io/apidoc#operation/PolygonBlockchainTransfer 134 | matic transaction deploy 135 | 136 | ## NFT blockchain operations, API key is required 137 | nft get address
https://tatum.io/apidoc#operation/NftGetBalanceErc721 138 | nft get contractaddress https://tatum.io/apidoc#operation/NftGetContractAddress 139 | nft get uri https://tatum.io/apidoc#operation/NftGetMetadataErc721 140 | nft get royalty https://tatum.io/apidoc#operation/NftGetRoyaltyErc721 141 | nft transaction deploy https://tatum.io/apidoc#operation/NftDeployErc721 142 | nft transaction mint https://tatum.io/apidoc#operation/NftMintErc721 143 | nft transaction mintbatch https://tatum.io/apidoc#operation/NftMintMultipleErc721 144 | nft transaction burn https://tatum.io/apidoc#operation/NftBurnErc721 145 | nft transaction transfer https://tatum.io/apidoc#operation/NftTransferErc721 146 | nft transaction update https://tatum.io/apidoc#operation/NftUpdateCashbackErc721 147 | 148 | ## MultiToken blockchain operations, API key is required 149 | multitoken get balance
https://tatum.io/apidoc#operation/MultiTokenGetBalance 150 | multitoken get balancebatch
https://tatum.io/apidoc#operation/MultiTokenGetBalanceBatch 151 | multitoken get contractaddress https://tatum.io/apidoc#operation/MultiTokenGetContractAddress 152 | multitoken get transaction https://tatum.io/apidoc#operation/MultiTokenGetTransaction 153 | multitoken get metadata https://tatum.io/apidoc#operation/MultiTokenGetMetadata 154 | multitoken transaction deploy https://tatum.io/apidoc#operation/DeployMultiToken 155 | multitoken transaction mint https://tatum.io/apidoc#operation/MintMultiToken 156 | multitoken transaction mintbatch https://tatum.io/apidoc#operation/MintMultiTokenBatch 157 | multitoken transaction burn https://tatum.io/apidoc#operation/BurnMultiToken 158 | multitoken transaction burnbatch https://tatum.io/apidoc#operation/BurnMultiTokenBatch 159 | multitoken transaction transfer https://tatum.io/apidoc#operation/TransferMultiToken 160 | multitoken transaction transferbatch https://tatum.io/apidoc#operation/TransferMultiTokenBatch 161 | 162 | ## Litecoin blockchain operations, API key is required 163 | litecoin block current https://tatum.io/apidoc#operation/LtcGetBlockChainInfo 164 | litecoin block hash https://tatum.io/apidoc#operation/LtcGetBlockHash 165 | litecoin block detail https://tatum.io/apidoc#operation/LtcGetBlock 166 | litecoin transaction detail https://tatum.io/apidoc#operation/LtcGetRawTransaction 167 | litecoin transaction address
https://tatum.io/apidoc#operation/LtcGetTxByAddress 168 | litecoin transaction utxo https://tatum.io/apidoc#operation/LtcGetUTXO 169 | litecoin transaction broadcast https://tatum.io/apidoc#operation/LtcBroadcast 170 | litecoin transaction create https://tatum.io/apidoc#operation/LtcTransferBlockchain 171 | 172 | ## Bitcoin Cash blockchain operations, API key is required 173 | bcash block current https://tatum.io/apidoc#operation/BchGetBlockChainInfo 174 | bcash block hash https://tatum.io/apidoc#operation/BchGetBlockHash 175 | bcash block detail https://tatum.io/apidoc#operation/BchGetBlock 176 | bcash transaction detail https://tatum.io/apidoc#operation/BchGetRawTransaction 177 | bcash transaction address
https://tatum.io/apidoc#operation/BchGetTxByAddress 178 | bcash transaction broadcast https://tatum.io/apidoc#operation/BchBroadcast 179 | bcash transaction create https://tatum.io/apidoc#operation/BchTransferBlockchain 180 | 181 | ## XRP blockchain operations, API key is required 182 | xrp ledger current https://tatum.io/apidoc#operation/XrpGetLastClosedLedger 183 | xrp ledger detail https://tatum.io/apidoc#operation/XrpGetLedger 184 | xrp fee https://tatum.io/apidoc#operation/XrpGetFee 185 | xrp account detail
https://tatum.io/apidoc#operation/XrpGetAccountInfo 186 | xrp account balance
https://tatum.io/apidoc#operation/XrpGetAccountBalance 187 | xrp transaction detail https://tatum.io/apidoc#operation/XrpGetTransaction 188 | xrp transaction address
https://tatum.io/apidoc#operation/XrpGetAccountTx 189 | xrp transaction broadcast https://tatum.io/apidoc#operation/XrpBroadcast 190 | xrp transaction create https://tatum.io/apidoc#operation/XrpTransferBlockchain 191 | 192 | ## Stellar XLM blockchain operations, API key is required 193 | stellar ledger current https://tatum.io/apidoc#operation/XlmGetLastClosedLedger 194 | stellar ledger detail https://tatum.io/apidoc#operation/XlmGetLedger 195 | stellar fee https://tatum.io/apidoc#operation/XlmGetFee 196 | stellar account detail
https://tatum.io/apidoc#operation/XlmGetAccountInfo 197 | stellar transaction detail https://tatum.io/apidoc#operation/XlmGetTransaction 198 | stellar transaction ledger https://tatum.io/apidoc#operation/XlmGetLedgerTx 199 | stellar transaction address
https://tatum.io/apidoc#operation/XlmGetAccountTx 200 | stellar transaction broadcast https://tatum.io/apidoc#operation/XlmBroadcast 201 | stellar transaction create https://tatum.io/apidoc#operation/XlmTransferBlockchain 202 | 203 | ## Account operations within Tatum Private Ledger, API key is necessary 204 | ledger account create https://tatum.io/apidoc#operation/createAccount 205 | ledger account detail https://tatum.io/apidoc#operation/getAccountByAccountId 206 | ledger account list https://tatum.io/apidoc#operation/getAllAccounts 207 | ledger account list customer https://tatum.io/apidoc#operation/getAccountsByCustomerId 208 | ledger account balance https://tatum.io/apidoc#operation/getAccountByAccountId 209 | ledger account block https://tatum.io/apidoc#operation/blockAmount 210 | ledger account block list https://tatum.io/apidoc#operation/getBlockAmount 211 | ledger account unblock https://tatum.io/apidoc#operation/deleteBlockAmount 212 | ledger account unblock account https://tatum.io/apidoc#operation/deleteAllBlockAmount 213 | ledger account freeze https://tatum.io/apidoc#operation/freezeAccount 214 | ledger account unfreeze https://tatum.io/apidoc#operation/unfreezeAccount 215 | ledger account activate https://tatum.io/apidoc#operation/activateAccount 216 | ledger account deactivate https://tatum.io/apidoc#operation/deactivateAccount 217 | 218 | ## Customer operations within Tatum Private Ledger, API key is necessary 219 | ledger customer update https://tatum.io/apidoc#operation/updateCustomer 220 | ledger customer detail https://tatum.io/apidoc#operation/getCustomerByExternalId 221 | ledger customer list https://tatum.io/apidoc#operation/findAllCustomers 222 | ledger customer enable https://tatum.io/apidoc#operation/enableCustomer 223 | ledger customer disable https://tatum.io/apidoc#operation/disableCustomer 224 | ledger customer activate https://tatum.io/apidoc#operation/activateCustomer 225 | ledger customer deactivate https://tatum.io/apidoc#operation/deactivateCustomer 226 | 227 | ## Transaction operations within Tatum Private Ledger, API key is necessary 228 | ledger transaction create https://tatum.io/apidoc#operation/sendTransaction 229 | ledger transaction detail https://tatum.io/apidoc#operation/getTransactionsByReference 230 | ledger transaction list ledger https://tatum.io/apidoc#operation/getTransactions 231 | ledger transaction list account https://tatum.io/apidoc#operation/getTransactionsByAccountId 232 | ledger transaction list customer https://tatum.io/apidoc#operation/getTransactionsByCustomerId 233 | 234 | ## Virtual currency operations within Tatum Private Ledger, API key is necessary 235 | ledger vc create https://tatum.io/apidoc#operation/createCurrency 236 | ledger vc detail https://tatum.io/apidoc#operation/getCurrency 237 | ledger vc update https://tatum.io/apidoc#operation/updateCurrency 238 | ledger vc mint https://tatum.io/apidoc#operation/mintCurrency 239 | ledger vc revoke https://tatum.io/apidoc#operation/revokeCurrency 240 | 241 | ## Offchain operations, API key is necessary 242 | offchain account address create https://tatum.io/apidoc#operation/generateDepositAddress 243 | offchain account address list https://tatum.io/apidoc#operation/getAllDepositAddresses 244 | offchain account address exist
[--index,i] https://tatum.io/apidoc#operation/addressExists 245 | offchain account address delete
https://tatum.io/apidoc#operation/removeAddress 246 | offchain account address assign
https://tatum.io/apidoc#operation/assignAddress 247 | 248 | offchain withdrawal create https://tatum.io/apidoc#operation/storeWithdrawal 249 | offchain withdrawal complete https://tatum.io/apidoc#operation/completeWithdrawal 250 | offchain withdrawal cancel https://tatum.io/apidoc#operation/cancelInProgressWithdrawal 251 | offchain withdrawal broadcast https://tatum.io/apidoc#operation/broadcastBlockchainTransaction 252 | 253 | offchain transaction bitcoin create https://tatum.io/apidoc#operation/BtcTransfer 254 | offchain transaction litecoin create https://tatum.io/apidoc#operation/BchTransfer 255 | offchain transaction bcash create https://tatum.io/apidoc#operation/LtcTransfer 256 | offchain transaction ethereum create https://tatum.io/apidoc#operation/EthTransfer 257 | offchain transaction ethereum erc20 create https://tatum.io/apidoc#operation/EthTransferErc20 258 | offchain transaction xrp create https://tatum.io/apidoc#operation/XrpTransfer 259 | offchain transaction stellar create https://tatum.io/apidoc#operation/XlmTransfer 260 | 261 | Options 262 | --api-key, -a Tatum API Key to communicate with Tatum API. Necessary only for API requests to the Tatum. 263 | --x-quorum-endpoint, -q URL of the Quorum network 264 | --index, -i Optional index for off-chain account address methods. 265 | --version, -v Version of the CLI tool. 266 | 267 | `; 268 | 269 | export const print = (data: any) => console.log(JSON.stringify(data, null, 2)); 270 | 271 | export const parse = (data: string) => data.startsWith('\'') && data.endsWith('\'') ? JSON.parse(data.slice(1, -1).replace(/\\/g, '')) : JSON.parse(data.replace(/\\/g, '')); 272 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // tslint:disable-next-line:ordered-imports 3 | import { 4 | activateAccount, 5 | activateCustomer, assignDepositAddress, 6 | bcashBroadcast, 7 | bcashGetBlock, 8 | bcashGetBlockHash, 9 | bcashGetCurrentBlock, 10 | bcashGetTransaction, 11 | bcashGetTxForAccount, 12 | blockAmount, 13 | bscBroadcast, 14 | bscGetAccountBalance, 15 | bscGetAccountBep20Address, 16 | bscGetBlock, 17 | bscGetCurrentBlock, 18 | bscGetTransaction, 19 | bscGetTransactionsCount, 20 | btcBroadcast, 21 | btcGetBlock, 22 | btcGetBlockHash, 23 | btcGetCurrentBlock, 24 | btcGetTransaction, 25 | btcGetTxForAccount, 26 | btcGetUTXO, checkAddressExists, 27 | createAccount, 28 | createVirtualCurrency, 29 | Currency, 30 | deactivateAccount, 31 | deactivateCustomer, 32 | deleteBlockedAmount, 33 | deleteBlockedAmountForAccount, 34 | deployMultiToken, 35 | deployNFT, 36 | burnMultiToken, 37 | burnMultiTokenBatch, 38 | burnNFT, 39 | disableCustomer, 40 | enableCustomer, 41 | ethBroadcast, 42 | ethGetAccountBalance, 43 | ethGetAccountErc20Address, 44 | ethGetAccountTransactions, 45 | ethGetBlock, 46 | ethGetCurrentBlock, 47 | ethGetTransaction, 48 | ethGetTransactionsCount, 49 | freezeAccount, 50 | generateAddressFromXPub, generateDepositAddress, 51 | generatePrivateKeyFromMnemonic, 52 | generateWallet, 53 | getAccountBalance, 54 | getAccountById, 55 | getAccountsByCustomerId, 56 | getAllAccounts, 57 | getAllCustomers, 58 | getBlockedAmountsByAccountId, 59 | getCustomer, getDepositAddressesForAccount, 60 | getLogRecord, 61 | getNFTContractAddress, 62 | getNFTMetadataURI, 63 | getNFTRoyalty, 64 | getNFTsByAddress, 65 | getTransactionsByAccount, 66 | getTransactionsByCustomer, 67 | getTransactionsByLedger, 68 | getTransactionsByReference, 69 | getVirtualCurrencyByName, 70 | ltcBroadcast, 71 | ltcGetBlock, 72 | ltcGetBlockHash, 73 | ltcGetCurrentBlock, 74 | ltcGetTransaction, 75 | ltcGetTxForAccount, 76 | ltcGetUTXO, 77 | mintMultipleNFTWithUri, 78 | mintMultiToken, 79 | mintMultiTokenBatch, 80 | mintNFTWithUri, 81 | mintVirtualCurrency, 82 | offchainBroadcast, offchainCancelWithdrawal, offchainCompleteWithdrawal, offchainStoreWithdrawal, polygonBroadcast, polygonGetAccountBalance, polygonGetBlock, polygonGetCurrentBlock, polygonGetTransaction, polygonGetTransactionsCount, removeDepositAddress, 83 | revokeVirtualCurrency, sendBitcoinCashOffchainTransaction, 84 | sendBitcoinCashTransaction, sendBitcoinOffchainTransaction, 85 | sendBitcoinTransaction, 86 | sendBscOffchainTransaction, 87 | sendBscOrBep20Transaction, 88 | sendCustomBep20Transaction, 89 | sendCustomErc20Transaction, 90 | sendDeployBep20Transaction, 91 | sendDeployErc20Transaction, sendEthErc20OffchainTransaction, sendEthOffchainTransaction, 92 | sendEthOrErc20Transaction, sendLitecoinOffchainTransaction, 93 | sendLitecoinTransaction, 94 | sendPolygonDeployErc20SignedTransaction, sendXlmOffchainTransaction, sendXlmTransaction, sendXrpOffchainTransaction, 95 | sendXrpTransaction, 96 | storeTransaction, 97 | transferMultiToken, 98 | transferMultiTokenBatch, 99 | transferNFT, 100 | unfreezeAccount, 101 | updateCashbackForAuthorNFT, 102 | updateCustomer, 103 | updateVirtualCurrency, xlmBroadcast, xlmGetAccountInfo, xlmGetAccountTransactions, 104 | xlmGetCurrentLedger, xlmGetFee, xlmGetLedger, xlmGetLedgerTx, xlmGetTransaction, 105 | xrpBroadcast, 106 | xrpGetAccountBalance, 107 | xrpGetAccountInfo, 108 | xrpGetAccountTransactions, 109 | xrpGetCurrentLedger, 110 | xrpGetFee, 111 | xrpGetLedger, 112 | xrpGetTransaction, 113 | sendPolygonTransaction, 114 | sendPolygonOffchainTransaction, 115 | getMultiTokensBalance, 116 | getMultiTokensBatchBalance, 117 | getMultiTokenTransaction, 118 | getMultiTokenContractAddress, 119 | getMultiTokenMetadata, 120 | xdcGetCurrentBlock, 121 | xdcGetBlock, 122 | xdcGetAccountBalance, 123 | xdcGetAccountErc20Balance, 124 | sendXdcOrErc20Transaction, 125 | sendXdcCustomErc20Transaction, 126 | xdcGetTransaction, 127 | xdcGetTransactionsCount, 128 | xdcBroadcast, 129 | xdcEstimateGas, 130 | sendXdcOffchainTransaction, 131 | dogeGetCurrentBlock, 132 | dogeGetBlockHash, 133 | dogeGetBlock, 134 | sendDogecoinTransaction, 135 | dogeGetUTXO, 136 | dogeBroadcast, 137 | dogeGetTransaction, 138 | celoGetCurrentBlock, 139 | celoGetBlock, 140 | celoGetAccountBalance, 141 | celoGetTransaction, 142 | celoGetTransactionsCount, 143 | celoBroadcast, 144 | sendCeloOrcUsdTransaction, 145 | sendCeloDeployErc20Transaction, 146 | sendCeloStoreDataSignedTransaction, 147 | sendStoreDataTransaction, 148 | sendStoreDataQuorumTransaction, 149 | sendPolygonStoreDataTransaction, 150 | sendXdcStoreDataTransaction, 151 | sendOneTransaction, 152 | sendOneDeploy20SignedTransaction, 153 | oneGetCurrentBlock, 154 | oneGetBlock, 155 | oneGetBalance, 156 | oneGetTransactionCount, 157 | oneBroadcast, 158 | oneGetTransaction, 159 | sendOneStoreDataTransaction, 160 | sendDogecoinOffchainTransaction, 161 | scryptaGetCurrentBlock, 162 | scryptaGetBlockHash, 163 | scryptaGetBlock, 164 | sendScryptaTransaction, 165 | scryptaGetUTXO, 166 | scryptaBroadcast, 167 | scryptaGetTransaction, 168 | sendCeloOffchainTransaction, 169 | adaGetBlockChainInfo, 170 | adaGetBlock, 171 | sendAdaTransaction, 172 | adaGetTransactionsByAccount, 173 | sendBscStoreDataTransaction, 174 | adaGetUtxos, 175 | adaBroadcast, 176 | adaGetTransaction, 177 | getQtumCurrentBlock, 178 | getQtumBlock, 179 | getQtumUTXOs, 180 | getQtumTransaction, 181 | getQtumTransactions, 182 | getQtumBalance, 183 | qtumBroadcast, 184 | ipfsUpload, 185 | ipfsGet, 186 | ipfsDelete 187 | } from '@tatumio/tatum'; 188 | import meow from 'meow'; 189 | import { Command } from './command'; 190 | import { helpMessage, parse, print } from './helper'; 191 | 192 | const { input: command, flags } = meow(helpMessage, { 193 | flags: { 194 | 'api-key': { 195 | type: 'string', 196 | alias: 'a' 197 | }, 198 | 'x-quorum-endpoint': { 199 | type: 'string', 200 | alias: 'q' 201 | }, 202 | index: { 203 | type: 'number', 204 | alias: 'i' 205 | }, 206 | version: { 207 | alias: 'v' 208 | } 209 | } 210 | }); 211 | 212 | const startup = async () => { 213 | if (command.length === 0) { 214 | console.log(helpMessage); 215 | return; 216 | } 217 | if (flags.version) { 218 | console.log(require('package.json').version); 219 | return; 220 | } 221 | if (flags.apiKey) { 222 | process.env.TATUM_API_KEY = flags.apiKey as string; 223 | } else if (command[0].toLowerCase() !== Command.WALLET) { 224 | console.error('API key not provided. You can obtain one at https://tatum.io.'); 225 | process.exit(-1); 226 | return; 227 | } 228 | switch (command[0].toLowerCase()) { 229 | // local commands for operations with wallets 230 | case Command.WALLET: 231 | if (command[1].toLowerCase() === Command.CREATE) { 232 | print(await generateWallet(command[2].toUpperCase() as Currency, command[3].toLowerCase() === 'testnet', command.length === 5 ? command[4] : undefined)); 233 | } else if (command[1].toLowerCase() === Command.PRIVATE_KEY) { 234 | print(await generatePrivateKeyFromMnemonic(command[3].toUpperCase() as Currency, command[6].toLowerCase() === 'testnet', command[4], parseInt(command[5]))); 235 | } else if (command[1].toLowerCase() === Command.ADDRESS) { 236 | print(await generateAddressFromXPub(command[3].toUpperCase() as Currency, command[6].toLowerCase() === 'testnet', command[4], parseInt(command[5]))); 237 | } 238 | break; 239 | // commands that require API Key 240 | case Command.LEDGER: 241 | switch (command[1].toLowerCase()) { 242 | case Command.ACCOUNT: 243 | switch (command[2].toLowerCase()) { 244 | case Command.CREATE: 245 | print(await createAccount(parse(command.slice(3).join(' ')))); 246 | break; 247 | case Command.DETAIL: 248 | print(await getAccountById(command[3])); 249 | break; 250 | case Command.LIST: 251 | if (command[3].toLowerCase() === Command.CUSTOMER) { 252 | print(await getAccountsByCustomerId(command[4], parseInt(command[5]), parseInt(command[6]))); 253 | } else { 254 | print(await getAllAccounts(parseInt(command[3]), parseInt(command[4]))); 255 | } 256 | break; 257 | case Command.BALANCE: 258 | print(await getAccountBalance(command[3])); 259 | break; 260 | case Command.BLOCK: 261 | if (command[3].toLowerCase() === Command.LIST) { 262 | print(await getBlockedAmountsByAccountId(command[4], parseInt(command[5]), parseInt(command[6]))); 263 | } else { 264 | print(await blockAmount(command[3], parse(command.slice(4).join(' ')))); 265 | } 266 | break; 267 | case Command.UNBLOCK: 268 | if (command[3].toLowerCase() === Command.ACCOUNT) { 269 | await deleteBlockedAmountForAccount(command[4]); 270 | print({ status: 'OK' }); 271 | } else { 272 | await deleteBlockedAmount(command[3]); 273 | print({ status: 'OK' }); 274 | } 275 | break; 276 | case Command.FREEZE: 277 | await freezeAccount(command[3]); 278 | print({ status: 'OK' }); 279 | break; 280 | case Command.UNFREEZE: 281 | await unfreezeAccount(command[3]); 282 | print({ status: 'OK' }); 283 | break; 284 | case Command.ACTIVATE: 285 | await activateAccount(command[3]); 286 | print({ status: 'OK' }); 287 | break; 288 | case Command.DEACTIVATE: 289 | await deactivateAccount(command[3]); 290 | print({ status: 'OK' }); 291 | break; 292 | } 293 | break; 294 | case Command.CUSTOMER: 295 | switch (command[2].toLowerCase()) { 296 | case Command.ENABLE: 297 | await enableCustomer(command[3]); 298 | print({ status: 'OK' }); 299 | break; 300 | case Command.DISABLE: 301 | await disableCustomer(command[3]); 302 | print({ status: 'OK' }); 303 | break; 304 | case Command.ACTIVATE: 305 | await activateCustomer(command[3]); 306 | print({ status: 'OK' }); 307 | break; 308 | case Command.DEACTIVATE: 309 | await deactivateCustomer(command[3]); 310 | print({ status: 'OK' }); 311 | break; 312 | case Command.LIST: 313 | print(await getAllCustomers(parseInt(command[3]), parseInt(command[4]))); 314 | break; 315 | case Command.UPDATE: 316 | print(await updateCustomer(command[3], parse(command.slice(4).join(' ')))); 317 | break; 318 | case Command.DETAIL: 319 | print(await getCustomer(command[3])); 320 | break; 321 | } 322 | break; 323 | case Command.TRANSACTION: 324 | switch (command[2].toLowerCase()) { 325 | case Command.CREATE: 326 | print(await storeTransaction(parse(command.slice(3).join(' ')))); 327 | break; 328 | case Command.DETAIL: 329 | print(await getTransactionsByReference(command[3])); 330 | break; 331 | case Command.LIST: 332 | switch (command[3].toLowerCase()) { 333 | case Command.LEDGER: 334 | print(await getTransactionsByLedger(parse(command.slice(6).join(' ')), parseInt(command[4]), parseInt(command[5]))); 335 | break; 336 | case Command.ACCOUNT: 337 | print(await getTransactionsByAccount(parse(command.slice(6).join(' ')), parseInt(command[4]), parseInt(command[5]))); 338 | break; 339 | case Command.CUSTOMER: 340 | print(await getTransactionsByCustomer(parse(command.slice(6).join(' ')), parseInt(command[4]), parseInt(command[5]))); 341 | break; 342 | } 343 | break; 344 | } 345 | break; 346 | case Command.VC: 347 | switch (command[2].toLowerCase()) { 348 | case Command.CREATE: 349 | print(await createVirtualCurrency(parse(command.slice(3).join(' ')))); 350 | break; 351 | case Command.DETAIL: 352 | print(await getVirtualCurrencyByName(command[3])); 353 | break; 354 | case Command.UPDATE: 355 | await updateVirtualCurrency(parse(command.slice(3).join(' '))); 356 | print({ status: 'OK' }); 357 | break; 358 | case Command.MINT: 359 | print(await mintVirtualCurrency(parse(command.slice(3).join(' ')))); 360 | break; 361 | case Command.REVOKE: 362 | print(await revokeVirtualCurrency(parse(command.slice(3).join(' ')))); 363 | break; 364 | } 365 | break; 366 | } 367 | break; 368 | case Command.OFFCHAIN: 369 | switch (command[1].toLowerCase()) { 370 | case Command.ACCOUNT: 371 | switch (command[3].toLowerCase()) { 372 | case Command.CREATE: 373 | print(await generateDepositAddress(command[4], flags.index)); 374 | break; 375 | case Command.ASSIGN: 376 | print(await assignDepositAddress(command[4], command[5])); 377 | break; 378 | case Command.LIST: 379 | print(await getDepositAddressesForAccount(command[4])); 380 | break; 381 | case Command.EXIST: 382 | print(await checkAddressExists(command[4], command[5], flags.index)); 383 | break; 384 | case Command.DELETE: 385 | await removeDepositAddress(command[4], command[5]); 386 | print({ status: 'OK' }); 387 | break; 388 | } 389 | break; 390 | case Command.WITHDRAWAL: 391 | switch (command[2].toLowerCase()) { 392 | case Command.CREATE: 393 | print(await offchainStoreWithdrawal(parse(command.slice(3).join(' ')))); 394 | break; 395 | case Command.COMPLETE: 396 | await offchainCompleteWithdrawal(command[3], command[4]); 397 | print({ status: 'OK' }); 398 | break; 399 | case Command.CANCEL: 400 | await offchainCancelWithdrawal(command[3], command[4].toLowerCase() === 'true'); 401 | print({ status: 'OK' }); 402 | break; 403 | case Command.BROADCAST: 404 | print(await offchainBroadcast(parse(command.slice(3).join(' ')))); 405 | break; 406 | } 407 | break; 408 | case Command.TRANSACTION: 409 | switch (command[2].toLowerCase()) { 410 | case Command.BITCOIN: 411 | print(await sendBitcoinOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 412 | break; 413 | case Command.LITECOIN: 414 | print(await sendLitecoinOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 415 | break; 416 | case Command.BCH: 417 | print(await sendBitcoinCashOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 418 | break; 419 | case Command.XRP: 420 | print(await sendXrpOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 421 | break; 422 | case Command.XLM: 423 | print(await sendXlmOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 424 | break; 425 | case Command.XDC: 426 | print(await sendXdcOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 427 | break; 428 | case Command.ETHEREUM: 429 | switch (command[3].toLowerCase()) { 430 | case Command.ERC20: 431 | print(await sendEthErc20OffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 432 | break; 433 | case Command.CREATE: 434 | print(await sendEthOffchainTransaction(command[4].toLowerCase() === 'testnet', parse(command.slice(5).join(' ')))); 435 | break; 436 | } 437 | break; 438 | case Command.BSC: 439 | print(await sendBscOffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 440 | break; 441 | case Command.MATIC: 442 | print(await sendPolygonOffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 443 | break; 444 | case Command.DOGECOIN: 445 | print(await sendDogecoinOffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 446 | break; 447 | case Command.XDC: 448 | print(await sendXdcOffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 449 | break; 450 | case Command.CELO: 451 | print(await sendCeloOffchainTransaction(command[5].toLowerCase() === 'testnet', parse(command.slice(6).join(' ')))); 452 | break; 453 | } 454 | break; 455 | } 456 | break; 457 | case Command.BITCOIN: 458 | switch (command[1].toLowerCase()) { 459 | case Command.BLOCK: 460 | switch (command[2].toLowerCase()) { 461 | case Command.CURRENT: 462 | print(await btcGetCurrentBlock()); 463 | break; 464 | case Command.HASH: 465 | print(await btcGetBlockHash(parseInt(command[3]))); 466 | break; 467 | case Command.DETAIL: 468 | print(await btcGetBlock(command[3])); 469 | break; 470 | } 471 | break; 472 | case Command.TRANSACTION: 473 | switch (command[2].toLowerCase()) { 474 | case Command.CREATE: 475 | print(await sendBitcoinTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 476 | break; 477 | case Command.ADDRESS: 478 | print(await btcGetTxForAccount(command[3], parseInt(command[4]), parseInt(command[5]))); 479 | break; 480 | case Command.UTXO: 481 | print(await btcGetUTXO(command[3], parseInt(command[4]))); 482 | break; 483 | case Command.BROADCAST: 484 | print(await btcBroadcast(command[3])); 485 | break; 486 | case Command.DETAIL: 487 | print(await btcGetTransaction(command[3])); 488 | break; 489 | } 490 | break; 491 | } 492 | break; 493 | case Command.IPFS: 494 | switch (command[1].toLowerCase()) { 495 | case Command.STORE: 496 | print(await ipfsUpload(Buffer.from(command[2], 'utf-8'),command[3])) 497 | break; 498 | case Command.GET: 499 | print(await ipfsGet(command[2])) 500 | break; 501 | case Command.DELETE: 502 | print(await ipfsDelete(command[2])) 503 | break; 504 | } 505 | case Command.ADA: 506 | switch (command[1].toLowerCase()) { 507 | case Command.BLOCK: 508 | switch (command[2].toLowerCase()) { 509 | case Command.CURRENT: 510 | print(await adaGetBlockChainInfo()); 511 | break; 512 | case Command.DETAIL: 513 | print(await adaGetBlock(command[3])); 514 | break; 515 | } 516 | break; 517 | case Command.TRANSACTION: 518 | switch (command[2].toLowerCase()) { 519 | case Command.CREATE: 520 | print(await sendAdaTransaction(parse(command.slice(4).join(' ')))); 521 | break; 522 | case Command.ADDRESS: 523 | print(await adaGetTransactionsByAccount(command[3], parseInt(command[4]), parseInt(command[5]))); 524 | break; 525 | case Command.UTXO: 526 | print(await adaGetUtxos(command[3])); 527 | break; 528 | case Command.BROADCAST: 529 | print(await adaBroadcast(command[3])); 530 | break; 531 | case Command.DETAIL: 532 | print(await adaGetTransaction(command[3])); 533 | break; 534 | } 535 | break; 536 | } 537 | break; 538 | case Command.QTUM: 539 | switch (command[1].toLowerCase()) { 540 | case Command.BLOCK: 541 | switch (command[2].toLowerCase()) { 542 | case Command.CURRENT: 543 | print(await getQtumCurrentBlock()); 544 | break; 545 | case Command.DETAIL: 546 | print(await getQtumBlock(command[3])); 547 | break; 548 | } 549 | break; 550 | case Command.ACCOUNT: 551 | print(await getQtumBalance(command[2])) 552 | break; 553 | case Command.TRANSACTION: 554 | switch (command[2].toLowerCase()) { 555 | case Command.ADDRESS: 556 | print(await getQtumTransactions(command[3], parseInt(command[4]), parseInt(command[5]))); 557 | break; 558 | case Command.UTXO: 559 | print(await getQtumUTXOs(command[3])); 560 | break; 561 | case Command.BROADCAST: 562 | print(await qtumBroadcast(command[3])); 563 | break; 564 | case Command.DETAIL: 565 | print(await getQtumTransaction(command[3])); 566 | break; 567 | } 568 | break; 569 | } 570 | break; 571 | case Command.DOGECOIN: 572 | switch (command[1].toLowerCase()) { 573 | case Command.BLOCK: 574 | switch (command[2].toLowerCase()) { 575 | case Command.CURRENT: 576 | print(await dogeGetCurrentBlock()); 577 | break; 578 | case Command.HASH: 579 | print(await dogeGetBlockHash(parseInt(command[3]))); 580 | break; 581 | case Command.DETAIL: 582 | print(await dogeGetBlock(command[3])); 583 | break; 584 | } 585 | break; 586 | case Command.TRANSACTION: 587 | switch (command[2].toLowerCase()) { 588 | case Command.CREATE: 589 | print(await sendDogecoinTransaction(parse(command.slice(3).join(' ')))); 590 | break; 591 | case Command.UTXO: 592 | print(await dogeGetUTXO(command[3], parseInt(command[4]))); 593 | break; 594 | case Command.BROADCAST: 595 | print(await dogeBroadcast(command[3])); 596 | break; 597 | case Command.DETAIL: 598 | print(await dogeGetTransaction(command[3])); 599 | break; 600 | } 601 | break; 602 | } 603 | break; 604 | case Command.SCRYPTA: 605 | switch (command[1].toLowerCase()) { 606 | case Command.BLOCK: 607 | switch (command[2].toLowerCase()) { 608 | case Command.CURRENT: 609 | print(await scryptaGetCurrentBlock()); 610 | break; 611 | case Command.HASH: 612 | print(await scryptaGetBlockHash(parseInt(command[3]))); 613 | break; 614 | case Command.DETAIL: 615 | print(await scryptaGetBlock(command[3])); 616 | break; 617 | } 618 | break; 619 | case Command.TRANSACTION: 620 | switch (command[2].toLowerCase()) { 621 | case Command.CREATE: 622 | print(await sendScryptaTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 623 | break; 624 | case Command.UTXO: 625 | print(await scryptaGetUTXO(command[3], parseInt(command[4]))); 626 | break; 627 | case Command.BROADCAST: 628 | print(await scryptaBroadcast(command[3])); 629 | break; 630 | case Command.DETAIL: 631 | print(await scryptaGetTransaction(command[3])); 632 | break; 633 | } 634 | break; 635 | } 636 | break; 637 | case Command.LITECOIN: 638 | switch (command[1].toLowerCase()) { 639 | case Command.BLOCK: 640 | switch (command[2].toLowerCase()) { 641 | case Command.CURRENT: 642 | print(await ltcGetCurrentBlock()); 643 | break; 644 | case Command.HASH: 645 | print(await ltcGetBlockHash(parseInt(command[3]))); 646 | break; 647 | case Command.DETAIL: 648 | print(await ltcGetBlock(command[3])); 649 | break; 650 | } 651 | break; 652 | case Command.TRANSACTION: 653 | switch (command[2].toLowerCase()) { 654 | case Command.CREATE: 655 | print(await sendLitecoinTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 656 | break; 657 | case Command.ADDRESS: 658 | print(await ltcGetTxForAccount(command[3], parseInt(command[4]), parseInt(command[5]))); 659 | break; 660 | case Command.UTXO: 661 | print(await ltcGetUTXO(command[3], parseInt(command[4]))); 662 | break; 663 | case Command.BROADCAST: 664 | print(await ltcBroadcast(command[3])); 665 | break; 666 | case Command.DETAIL: 667 | print(await ltcGetTransaction(command[3])); 668 | break; 669 | } 670 | break; 671 | } 672 | break; 673 | case Command.BSC: 674 | switch (command[1].toLowerCase()) { 675 | case Command.BLOCK: 676 | switch (command[2].toLowerCase()) { 677 | case Command.CURRENT: 678 | print(await bscGetCurrentBlock()); 679 | break; 680 | case Command.DETAIL: 681 | print(await bscGetBlock(command[3])); 682 | break; 683 | } 684 | break; 685 | case Command.ACCOUNT: 686 | switch (command[2].toLowerCase()) { 687 | case Command.BSC: 688 | print(await bscGetAccountBalance(command[3])); 689 | break; 690 | case Command.BEP20: 691 | print(await bscGetAccountBep20Address(command[3], command[4])); 692 | break; 693 | } 694 | break; 695 | case Command.TRANSACTION: 696 | switch (command[2].toLowerCase()) { 697 | case Command.CREATE: 698 | switch (command[3].toLowerCase()) { 699 | case Command.BSC: 700 | print(await sendBscOrBep20Transaction(parse(command.slice(4).join(' ')))); 701 | break; 702 | case Command.BEP20: 703 | print(await sendCustomBep20Transaction(parse(command.slice(4).join(' ')))); 704 | break; 705 | } 706 | break; 707 | case Command.DEPLOY: 708 | print(await sendDeployBep20Transaction(parse(command.slice(3).join(' ')))); 709 | break; 710 | case Command.COUNT: 711 | print(await bscGetTransactionsCount(command[3])); 712 | break; 713 | case Command.BROADCAST: 714 | print(await bscBroadcast(command[3])); 715 | break; 716 | case Command.DETAIL: 717 | print(await bscGetTransaction(command[3])); 718 | break; 719 | } 720 | break; 721 | } 722 | break; 723 | case Command.MATIC: 724 | switch (command[1].toLowerCase()) { 725 | case Command.BLOCK: 726 | switch (command[2].toLowerCase()) { 727 | case Command.CURRENT: 728 | print(await polygonGetCurrentBlock()); 729 | break; 730 | case Command.DETAIL: 731 | print(await polygonGetBlock(command[3])); 732 | break; 733 | } 734 | break; 735 | case Command.ACCOUNT: 736 | print(await polygonGetAccountBalance(command[2])); 737 | break; 738 | case Command.TRANSACTION: 739 | switch (command[2].toLowerCase()) { 740 | case Command.CREATE: 741 | print(await sendPolygonTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 742 | break; 743 | case Command.DEPLOY: 744 | print(await sendPolygonDeployErc20SignedTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(3).join(' ')))); 745 | break; 746 | case Command.COUNT: 747 | print(await polygonGetTransactionsCount(command[3])); 748 | break; 749 | case Command.BROADCAST: 750 | print(await polygonBroadcast(command[3])); 751 | break; 752 | case Command.DETAIL: 753 | print(await polygonGetTransaction(command[3])); 754 | break; 755 | } 756 | break; 757 | } 758 | break; 759 | case Command.NFT: 760 | switch (command[1].toLowerCase()) { 761 | case Command.TRANSACTION: 762 | switch (command[2].toLowerCase()) { 763 | case Command.DEPLOY: 764 | print(await deployNFT(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 765 | break; 766 | case Command.MINT: 767 | print(await mintNFTWithUri(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 768 | break; 769 | case Command.MINTBATCH: 770 | print(await mintMultipleNFTWithUri(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 771 | case Command.BURN: 772 | print(await burnNFT(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 773 | break; 774 | case Command.TRANSFER: 775 | print(await transferNFT(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 776 | break; 777 | case Command.UPDATE: 778 | print(updateCashbackForAuthorNFT(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 779 | break; 780 | } 781 | break; 782 | case Command.GET: 783 | let currencyString = command[3] as keyof typeof Currency; 784 | switch (command[2].toLowerCase()) { 785 | case Command.ADDRESS: 786 | print(await getNFTsByAddress(Currency[currencyString], command[4], command[5])); 787 | case Command.CONTRACTADDRESS: 788 | print(await getNFTContractAddress(Currency[currencyString], command[4])); 789 | break; 790 | case Command.URI: 791 | print(await getNFTMetadataURI(Currency[currencyString], command[4], command[5])); 792 | break; 793 | case Command.ROYALTY: 794 | print(await getNFTRoyalty(Currency[currencyString], command[4], command[5])); 795 | break; 796 | } 797 | break; 798 | } 799 | break; 800 | case Command.MULTITOKEN: 801 | switch (command[1].toLowerCase()) { 802 | case Command.TRANSACTION: 803 | switch (command[2].toLowerCase()) { 804 | case Command.DEPLOY: 805 | print(await deployMultiToken(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 806 | break; 807 | case Command.MINT: 808 | print(await mintMultiToken(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 809 | break; 810 | case Command.MINTBATCH: 811 | print(await mintMultiTokenBatch(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 812 | case Command.BURN: 813 | print(await burnMultiToken(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 814 | break; 815 | case Command.BURNBATCH: 816 | print(await burnMultiTokenBatch(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))) 817 | break; 818 | case Command.TRANSFER: 819 | print(await transferMultiToken(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 820 | break; 821 | case Command.TRANSFERBATCH: 822 | print(await transferMultiTokenBatch(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 823 | break; 824 | } 825 | break; 826 | case Command.GET: 827 | let currencyString = command[3] as keyof typeof Currency; 828 | switch (command[2].toLowerCase()) { 829 | case Command.BALANCE: 830 | print(await getMultiTokensBalance(Currency[currencyString], command[4], command[5], command[6])); 831 | case Command.BALANCEBATCH: 832 | print(await getMultiTokensBatchBalance(Currency[currencyString], command[4], command[5], command[6])); 833 | case Command.TRANSACTION: 834 | print(await getMultiTokenTransaction(Currency[currencyString], command[4])); 835 | case Command.CONTRACTADDRESS: 836 | print(await getMultiTokenContractAddress(Currency[currencyString], command[4])); 837 | break; 838 | case Command.METADATA: 839 | print(await getMultiTokenMetadata(Currency[currencyString], command[4], command[5])); 840 | break; 841 | } 842 | break; 843 | } 844 | break; 845 | case Command.XDC: 846 | switch (command[1].toLowerCase()) { 847 | case Command.BLOCK: 848 | switch (command[2].toLowerCase()) { 849 | case Command.CURRENT: 850 | print(await xdcGetCurrentBlock()); 851 | break; 852 | case Command.DETAIL: 853 | print(await xdcGetBlock(command[3])); 854 | break; 855 | } 856 | break; 857 | case Command.ACCOUNT: 858 | switch (command[3].toLowerCase()) { 859 | case Command.XDC: 860 | print(await xdcGetAccountBalance(command[4])); 861 | break; 862 | case Command.ERC20: 863 | print(await xdcGetAccountErc20Balance(command[4], command[5])); 864 | break; 865 | } 866 | break; 867 | case Command.TRANSACTION: 868 | switch (command[2].toLowerCase()) { 869 | case Command.CREATE: 870 | switch (command[3].toLowerCase()) { 871 | case Command.XDC: 872 | print(await sendXdcOrErc20Transaction(parse(command.slice(5).join(' ')))); 873 | break; 874 | case Command.ERC20: 875 | print(await sendXdcCustomErc20Transaction(parse(command.slice(5).join(' ')))); 876 | break; 877 | } 878 | break; 879 | case Command.GAS: 880 | print(await xdcEstimateGas(parse(command.slice(3).join(' ')))); 881 | break; 882 | case Command.COUNT: 883 | print(await xdcGetTransactionsCount(command[3])); 884 | break; 885 | case Command.BROADCAST: 886 | print(await xdcBroadcast(command[3])); 887 | break; 888 | case Command.DETAIL: 889 | print(await xdcGetTransaction(command[3])); 890 | break; 891 | } 892 | break; 893 | } 894 | break; 895 | case Command.ETHEREUM: 896 | switch (command[1].toLowerCase()) { 897 | case Command.BLOCK: 898 | switch (command[2].toLowerCase()) { 899 | case Command.CURRENT: 900 | print(await ethGetCurrentBlock()); 901 | break; 902 | case Command.DETAIL: 903 | print(await ethGetBlock(command[3])); 904 | break; 905 | } 906 | break; 907 | case Command.ACCOUNT: 908 | switch (command[3].toLowerCase()) { 909 | case Command.ETHEREUM: 910 | print(await ethGetAccountBalance(command[4])); 911 | break; 912 | case Command.ERC20: 913 | print(await ethGetAccountErc20Address(command[4], command[5])); 914 | break; 915 | } 916 | break; 917 | case Command.TRANSACTION: 918 | switch (command[2].toLowerCase()) { 919 | case Command.CREATE: 920 | switch (command[3].toLowerCase()) { 921 | case Command.ETHEREUM: 922 | print(await sendEthOrErc20Transaction(parse(command.slice(5).join(' ')))); 923 | break; 924 | case Command.ERC20: 925 | print(await sendCustomErc20Transaction(parse(command.slice(5).join(' ')))); 926 | break; 927 | } 928 | break; 929 | case Command.ADDRESS: 930 | print(await ethGetAccountTransactions(command[3], parseInt(command[4]), parseInt(command[5]))); 931 | break; 932 | case Command.DEPLOY: 933 | print(await sendDeployErc20Transaction(parse(command.slice(5).join(' ')))); 934 | break; 935 | case Command.COUNT: 936 | print(await ethGetTransactionsCount(command[3])); 937 | break; 938 | case Command.BROADCAST: 939 | print(await ethBroadcast(command[3])); 940 | break; 941 | case Command.DETAIL: 942 | print(await ethGetTransaction(command[3])); 943 | break; 944 | } 945 | break; 946 | } 947 | break; 948 | case Command.ONE: 949 | switch (command[1].toLowerCase()) { 950 | case Command.BLOCK: 951 | switch (command[2].toLowerCase()) { 952 | case Command.CURRENT: 953 | print(await oneGetCurrentBlock()); 954 | break; 955 | case Command.DETAIL: 956 | print(await oneGetBlock(command[3])); 957 | break; 958 | } 959 | break; 960 | case Command.ACCOUNT: 961 | print(await oneGetBalance(command[2])); 962 | break; 963 | case Command.TRANSACTION: 964 | switch (command[2].toLowerCase()) { 965 | case Command.CREATE: 966 | print(await sendOneTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 967 | break; 968 | case Command.DEPLOY: 969 | print(await sendOneDeploy20SignedTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 970 | break; 971 | case Command.COUNT: 972 | print(await oneGetTransactionCount(command[3])); 973 | break; 974 | case Command.BROADCAST: 975 | print(await oneBroadcast(command[3])); 976 | break; 977 | case Command.DETAIL: 978 | print(await oneGetTransaction(command[3])); 979 | break; 980 | } 981 | break; 982 | } 983 | break; 984 | case Command.CELO: 985 | switch (command[1].toLowerCase()) { 986 | case Command.BLOCK: 987 | switch (command[2].toLowerCase()) { 988 | case Command.CURRENT: 989 | print(await celoGetCurrentBlock()); 990 | break; 991 | case Command.DETAIL: 992 | print(await celoGetBlock(command[3])); 993 | break; 994 | } 995 | break; 996 | case Command.ACCOUNT: 997 | print(await celoGetAccountBalance(command[2])); 998 | break; 999 | case Command.TRANSACTION: 1000 | switch (command[2].toLowerCase()) { 1001 | case Command.CREATE: 1002 | print(await sendCeloOrcUsdTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 1003 | break; 1004 | case Command.DEPLOY: 1005 | print(await sendCeloDeployErc20Transaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 1006 | break; 1007 | case Command.COUNT: 1008 | print(await celoGetTransactionsCount(command[3])); 1009 | break; 1010 | case Command.BROADCAST: 1011 | print(await celoBroadcast(command[3])); 1012 | break; 1013 | case Command.DETAIL: 1014 | print(await celoGetTransaction(command[3])); 1015 | break; 1016 | } 1017 | break; 1018 | } 1019 | break; 1020 | case Command.DATA: 1021 | switch (command[1].toLowerCase()) { 1022 | case Command.CREATE: 1023 | process.stdin.pipe(require('split')()).on('data', async (line: string) => { 1024 | if (line.trim().length === 0) { 1025 | return; 1026 | } 1027 | try { 1028 | switch (command[2].toUpperCase()) { 1029 | case Currency.QUORUM: 1030 | print(await sendStoreDataQuorumTransaction(parse(command.slice(3).join(' ')),command[4])); 1031 | break; 1032 | case Currency.ETH: 1033 | print(await sendStoreDataTransaction(parse(command.slice(3).join(' ')))); 1034 | break; 1035 | case Currency.CELO: 1036 | print(await sendCeloStoreDataSignedTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 1037 | break; 1038 | case Currency.MATIC: 1039 | print(await sendPolygonStoreDataTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 1040 | break; 1041 | case Currency.XDC: 1042 | print(await sendXdcStoreDataTransaction(parse(command.slice(3).join(' ')))); 1043 | break; 1044 | case Currency.ONE: 1045 | print(await sendOneStoreDataTransaction(command[3].toLowerCase() === 'testnet',parse(command.slice(4).join(' ')))); 1046 | break; 1047 | case Currency.BSC: 1048 | print(await sendBscStoreDataTransaction(parse(command.slice(4).join(' ')))); 1049 | break; 1050 | } 1051 | } catch (e) { 1052 | print(e.response ? e.response.data : e); 1053 | } 1054 | }); 1055 | break; 1056 | case Command.DETAIL: 1057 | print(await getLogRecord(command[2].toUpperCase() as Currency, command[3])); 1058 | break; 1059 | } 1060 | break; 1061 | case Command.BCH: 1062 | switch (command[1].toLowerCase()) { 1063 | case Command.BLOCK: 1064 | switch (command[2].toLowerCase()) { 1065 | case Command.CURRENT: 1066 | print(await bcashGetCurrentBlock()); 1067 | break; 1068 | case Command.HASH: 1069 | print(await bcashGetBlockHash(parseInt(command[3]))); 1070 | break; 1071 | case Command.DETAIL: 1072 | print(await bcashGetBlock(command[3])); 1073 | break; 1074 | } 1075 | break; 1076 | case Command.TRANSACTION: 1077 | switch (command[2].toLowerCase()) { 1078 | case Command.CREATE: 1079 | print(await sendBitcoinCashTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 1080 | break; 1081 | case Command.ADDRESS: 1082 | print(await bcashGetTxForAccount(command[3], parseInt(command[4]))); 1083 | break; 1084 | case Command.BROADCAST: 1085 | print(await bcashBroadcast(command[3])); 1086 | break; 1087 | case Command.DETAIL: 1088 | print(await bcashGetTransaction(command[3])); 1089 | break; 1090 | } 1091 | break; 1092 | } 1093 | break; 1094 | case Command.XRP: 1095 | switch (command[1].toLowerCase()) { 1096 | case Command.LEDGER: 1097 | switch (command[2].toLowerCase()) { 1098 | case Command.CURRENT: 1099 | print(await xrpGetCurrentLedger()); 1100 | break; 1101 | case Command.DETAIL: 1102 | print(await xrpGetLedger(parseInt(command[3]))); 1103 | break; 1104 | } 1105 | break; 1106 | case Command.ACCOUNT: 1107 | switch (command[2].toLowerCase()) { 1108 | case Command.BALANCE: 1109 | print(await xrpGetAccountBalance(command[3])); 1110 | break; 1111 | case Command.DETAIL: 1112 | print(await xrpGetAccountInfo(command[3])); 1113 | break; 1114 | } 1115 | break; 1116 | case Command.FEE: 1117 | print(await xrpGetFee()); 1118 | break; 1119 | case Command.TRANSACTION: 1120 | switch (command[2].toLowerCase()) { 1121 | case Command.CREATE: 1122 | print(await sendXrpTransaction(parse(command.slice(3).join(' ')))); 1123 | break; 1124 | case Command.ADDRESS: 1125 | print(await xrpGetAccountTransactions(command[3], parseInt(command[4]), command[5])); 1126 | break; 1127 | case Command.BROADCAST: 1128 | print(await xrpBroadcast(command[3])); 1129 | break; 1130 | case Command.DETAIL: 1131 | print(await xrpGetTransaction(command[3])); 1132 | break; 1133 | } 1134 | break; 1135 | } 1136 | break; 1137 | case Command.XLM: 1138 | switch (command[1].toLowerCase()) { 1139 | case Command.LEDGER: 1140 | switch (command[2].toLowerCase()) { 1141 | case Command.CURRENT: 1142 | print(await xlmGetCurrentLedger()); 1143 | break; 1144 | case Command.DETAIL: 1145 | print(await xlmGetLedger(parseInt(command[3]))); 1146 | break; 1147 | } 1148 | break; 1149 | case Command.ACCOUNT: 1150 | switch (command[2].toLowerCase()) { 1151 | case Command.DETAIL: 1152 | print(await xlmGetAccountInfo(command[3])); 1153 | break; 1154 | } 1155 | break; 1156 | case Command.FEE: 1157 | print(await xlmGetFee()); 1158 | break; 1159 | case Command.TRANSACTION: 1160 | switch (command[2].toLowerCase()) { 1161 | case Command.CREATE: 1162 | print(await sendXlmTransaction(command[3].toLowerCase() === 'testnet', parse(command.slice(4).join(' ')))); 1163 | break; 1164 | case Command.ADDRESS: 1165 | print(await xlmGetAccountTransactions(command[3])); 1166 | break; 1167 | case Command.LEDGER: 1168 | print(await xlmGetLedgerTx(parseInt(command[3]))); 1169 | break; 1170 | case Command.BROADCAST: 1171 | print(await xlmBroadcast(command[3])); 1172 | break; 1173 | case Command.DETAIL: 1174 | print(await xlmGetTransaction(command[3])); 1175 | break; 1176 | } 1177 | break; 1178 | } 1179 | break; 1180 | default: 1181 | console.error('Unsupported command. Use tatum --help for details.'); 1182 | process.exit(-1); 1183 | } 1184 | }; 1185 | 1186 | startup().catch(e => { 1187 | if (e.response) { 1188 | console.error(JSON.stringify(e.response.data, null, 2)); 1189 | } else { 1190 | console.error(e); 1191 | } 1192 | process.exit(-1); 1193 | }); 1194 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "outDir": "./dist", 6 | "strict": true, 7 | "baseUrl": "./", 8 | "lib": [ 9 | "ES2020" 10 | ], 11 | "typeRoots": [ 12 | "node_modules/@types" 13 | ], 14 | "types": [ 15 | "node", 16 | "jest" 17 | ], 18 | "esModuleInterop": true, 19 | "inlineSourceMap": true, 20 | "experimentalDecorators": true, 21 | "resolveJsonModule": true, 22 | "emitDecoratorMetadata": true, 23 | "strictPropertyInitialization": false 24 | }, 25 | "exclude": [ 26 | "node_modules", 27 | "dist" 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": { 7 | "no-unused-expression": true 8 | }, 9 | "rules": { 10 | "quotemark": [ 11 | true, 12 | "single" 13 | ], 14 | "member-access": [ 15 | true 16 | ], 17 | "ordered-imports": [ 18 | true 19 | ], 20 | "max-line-length": [ 21 | true, 22 | 180 23 | ], 24 | "interface-name": [ 25 | false 26 | ], 27 | "variable-name": false, 28 | "no-shadowed-variable": false, 29 | "max-classes-per-file": false, 30 | "radix": false, 31 | "no-empty": false, 32 | "no-console": false, 33 | "arrow-parens": false, 34 | "object-literal-sort-keys": false 35 | }, 36 | "rulesDirectory": [] 37 | } 38 | --------------------------------------------------------------------------------