{"id":21660203,"url":"https://github.com/loomnetwork/plasma-cli","last_synced_at":"2026-02-02T13:53:31.022Z","repository":{"id":33936862,"uuid":"149321554","full_name":"loomnetwork/plasma-cli","owner":"loomnetwork","description":"All In One stateful Plasma-Cash client, browser compatible","archived":false,"fork":false,"pushed_at":"2022-12-09T16:58:31.000Z","size":730,"stargazers_count":43,"open_issues_count":23,"forks_count":5,"subscribers_count":19,"default_branch":"master","last_synced_at":"2023-04-11T16:48:17.712Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loomnetwork.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-09-18T16:47:44.000Z","updated_at":"2022-11-14T19:50:03.000Z","dependencies_parsed_at":"2023-01-15T03:30:30.515Z","dependency_job_id":null,"html_url":"https://github.com/loomnetwork/plasma-cli","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loomnetwork%2Fplasma-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loomnetwork%2Fplasma-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loomnetwork%2Fplasma-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loomnetwork%2Fplasma-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loomnetwork","download_url":"https://codeload.github.com/loomnetwork/plasma-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226306132,"owners_count":17603935,"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":[],"created_at":"2024-11-25T09:32:29.413Z","updated_at":"2026-02-02T13:53:30.980Z","avatar_url":"https://github.com/loomnetwork.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# [Loom Network](https://loomx.io) Plasma Cash Client\n\nNode JS All in one Plasma Cash client.\n\n## Installation\n\n`npm install -g plasma-cli`\n\n\n## Usage\n\n```\nUsage: plasma-cli [options]\n\nOptions:\n  -V, --version                        output the version number\n  -d, --dappchain [dappchain-address]  The DAppChain's endpoint (default: \"http://localhost:46658\")\n  -e, --ethereum [web3-endpoint]       The web3 Ethereum endpoint (default: \"http://localhost:8545\")\n  -a, --address [plasma-address]       The Plasma Contract's address\n  --key [private-key]                  Your private key\n  --keystore [json-keystore]           Your private key in a file\n  -c --config [config-file]            Your config file\n  -h, --help                           output usage information\n```\n\n\n## Example connecting to Rinkeby \n\n### Config File\n\n`plasma-cli --keystore ./config/alice.json -c config/contracts.json -e wss://rinkeby.infura.io/ws`\n\n`alice.json` has your private key in hex form.\n`contract.json` has a `plasma` key which is the Plasma Contract's address, and a `block` parameter which should be the block at which the Plasma Contract was deployed. This is needed so that event filtering doesnt check from blocks before than the Plasma contract was deployed. \n\n### Command Line Arguments\n\n`plasma-cli --key \u003cyourprivatekey\u003e --address \u003cplasmacontractaddress\u003e --block \u003cstartblock\u003e -e wss://rinkeby.infura.io/ws`\n\n## Usage inside the CLI\n\n```\n\u003e help\n\n  Commands:\n\n    help [command...]                 Provides help for a given command.\n    exit                              Exits application.\n    myCoins                           Retrieves the user coins from the dappchain or from the state.\n    depositERC721 \u003caddress\u003e \u003ccoinId\u003e  Deposits an ERC721 coin to the Plasma Chain\n    depositERC20 \u003caddress\u003e \u003camount\u003e   Deposits an ERC20 coin to the Plasma Chain\n    depositETH \u003camount\u003e               Deposit ether to the Plasma Chain\n    deposits                          Gets all the deposits the user has made\n    exitCoin \u003ccoinId\u003e                 Start the exit of a coin from the Plasma Chain\n    transfer \u003ccoinId\u003e \u003cnewOwner\u003e      Send a coin to a new user\n    finalize \u003ccoinId\u003e                 Finalize the exit of a coin and withdraw it\n    refresh                           Refreshes the user's state\n    withdraw \u003ccoinId\u003e                 Gets the details about a coin\n    withdrawBonds                     Withdraws the user's bonds\n    receive \u003ccoinId\u003e                  Check coin history and watch exits\n    coin \u003ccoinId\u003e                     Gets the details about a coin\n```\n\nFirst, you need to deposit some funds to the Plasma Contract. You do this with one of the `deposit{ETH,ERC20,ERC721}` functions. \n\n## Examples\n\n### Deposit\n`depositETH 1000`: Will deposit 1000 Wei to the smart contract\n`depositERC20 0xa4e8c3ec456107ea67d3075bf9e3df3a75823db0 1000`: Will deposit 1000 Loom Tokens to the smart contract (with the approve/transferFrom pattern)\n`depositERC721 0x06012c8cf97bead5deae237070f9587f8e7a266d 124654`: Will deposit Cryptokitty #124654\n\nAfter the coin has been deposited, the CLI will return the data for that coin.\n\n```\n\u003e depositETH 100000\nDepositing 100000 Wei\nCoin deposited!\n{ slot: \u003cBN: e901f51acd48b12f\u003e,\n  blockNumber: \u003cBN: 7d1\u003e,\n  denomination: \u003cBN: 186a0\u003e,\n  from: '0x3D5Cf1f50C7124ACbC6ea69b96a912fE890619D0',\n  contractAddress: '0x3D5Cf1f50C7124ACbC6ea69b96a912fE890619D0' } // when a user deposits ETH, the contractAddress field is set to the user's address\n```\n\nThe user can then inspect the above information with the `coin` command: `coin e901f51acd48b12f`\n\n### Sending a coin\n\nIn order to transact then you can use the command `transfer`. This command will send the transaction, and also send a confirmation receipt of the txs inclusion, if the transaction is included within a set number of blocks (default 6). If not, the user can assume they are being censored and should exit. If successfuly included, it will also stop any watchers for the coin's exits.\n\n```\n\u003e transfer e901f51acd48b12f 0x82472162c3e7927557e7bcf5cca7261e188747d3\nTransferring e901f51acd48b12f to 0x82472162c3e7927557e7bcf5cca7261e188747d3\nTx(e901f51acd48b12f, 0x82472162c3e7927557e7bcf5cca7261e188747d3) included \u0026 verified in block 3000\n```\n\nThe receiver at this point shoudl call `receive`\n\n### Exiting a coin\n\nThis is as simple as calling `exitCoin`. The client will initiate an exit (and deposit the required security bond). It will also automatically trigger a watcher for challenges on that exit. \n\n```\n\u003e exitCoin e901f51acd48b12f\nExiting e901f51acd48b12f!\nExit initiated!\n\n\u003e coin e901f51acd48b12f\nRetrieving info for coin e901f51acd48b12f\n{ slot: \u003cBN: e901f51acd48b12f\u003e,\n  uid: \u003cBN: 0\u003e,\n  depositBlockNum: \u003cBN: 7d1\u003e,\n  denomination: \u003cBN: 186a0\u003e,\n  owner: '0x3D5Cf1f50C7124ACbC6ea69b96a912fE890619D0',\n  state: 1, // State = 1 indicates that it's currently under an exit\n  mode: 0,\n  contractAddress: '0x3D5Cf1f50C7124ACbC6ea69b96a912fE890619D0' }\n```\n\nAfter the dispute period has passed, they can finalize the exit, and withdraw the coin with their bonds. This will stop all watchers\n\n```\n\u003e finalize e901f51acd48b12f\nFinalized the exit for e901f51acd48b12f\n\n\u003e coin e901f51acd48b12f\nRetrieving info for coin e901f51acd48b12f\n{ slot: \u003cBN: e901f51acd48b12f\u003e,\n  uid: \u003cBN: 0\u003e,\n  depositBlockNum: \u003cBN: 7d1\u003e,\n  denomination: \u003cBN: 186a0\u003e,\n  owner: '0x82472162c3E7927557E7bCF5CCa7261E188747d3',\n  state: 2, // State = 2 indicates the exit has been finalized\n  mode: 0,\n  contractAddress: '0x3D5Cf1f50C7124ACbC6ea69b96a912fE890619D0' }\n\n\u003e withdraw e901f51acd48b12f\nWithdrawing e901f51acd48b12f\nWithdrew e901f51acd48b12f\n\n\u003e coin e901f51acd48b12f\nRetrieving info for coin e901f51acd48b12f\n{ slot: \u003cBN: e901f51acd48b12f\u003e,\n  uid: \u003cBN: 0\u003e,\n  depositBlockNum: \u003cBN: 0\u003e,\n  denomination: \u003cBN: 0\u003e,\n  owner: '0x0000000000000000000000000000000000000000',\n  state: 0,\n  mode: 0,\n  contractAddress: '0x0000000000000000000000000000000000000000' }\n\n\u003e withdrawBonds\nBonds withdrawn:)\n```\n\n## Deploy to Rinkeby\n\n```\nyarn\nREPO_ROOT=`pwd`\ngit clone https://github.com/loomnetwork/plasma-cash\ncd $REPO_ROOT/plasma-cash/server\ngit checkout deploy\nnpm install\nmnemonic=\"your mnemonic here\" .node_modules/bin/truffle migrate -f2 --network rinkeby\nPLASMA_ADDRESS=$(python -c \"import json ; print(json.load(open('./build/contracts/RootChain.json'))['networks']['4']['address'])\")\nERC721_ADDRESS=$(python -c \"import json ; print(json.load(open('./build/contracts/CryptoCards.json'))['networks']['4']['address'])\")\nERC20_ADDRESS=$(python -c \"import json ; print(json.load(open('./build/contracts/.json'))['networks']['4']['address'])\")\n```\n\nAt this moment, the Plasma contract has been deployed (along with the Validator Manager contract, and 2 toy tokens for you to play with). We need to put the `PLASMA_ADDRESS` in the loom.yml.\n\n\n```\ncd $REPO_ROOT/dappchain\ncurl https://raw.githubusercontent.com/loomnetwork/loom-sdk-documentation/master/scripts/get_loom.sh | sh\nchmod +x ./loom\n\n# Modify the Plasma contract's address\nsed -i -e \"s/PlasmaHexAddress:.*/PlasmaHexAddress: \\\"$PLASMA_ADDRESS\\\"/\" loom.yml\n\n# Initialize loom params - also initialize the oracle address\n./loom init -f\ncp oracle.genesis.json genesis.json\n\n./loom run\n```\n\nNow you have a Loom DAppchain running that has Plasma Cash deployed and is hooked to Rinkeby.\nYou can launch the CLI as described above and interact with it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floomnetwork%2Fplasma-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floomnetwork%2Fplasma-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floomnetwork%2Fplasma-cli/lists"}