{"id":15654450,"url":"https://github.com/driftluo/cita-cli","last_synced_at":"2025-08-30T02:04:59.601Z","repository":{"id":85864477,"uuid":"132994442","full_name":"driftluo/cita-cli","owner":"driftluo","description":"An easy-to-use CITA command line tool","archived":false,"fork":false,"pushed_at":"2020-02-10T02:37:13.000Z","size":4285,"stargazers_count":27,"open_issues_count":1,"forks_count":27,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-01T01:13:28.425Z","etag":null,"topics":["cita","cita-cli","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/driftluo.png","metadata":{"files":{"readme":"README-CN.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-11T05:41:10.000Z","updated_at":"2023-06-14T10:49:41.000Z","dependencies_parsed_at":"2023-03-08T10:30:59.304Z","dependency_job_id":null,"html_url":"https://github.com/driftluo/cita-cli","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/driftluo/cita-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftluo%2Fcita-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftluo%2Fcita-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftluo%2Fcita-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftluo%2Fcita-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/driftluo","download_url":"https://codeload.github.com/driftluo/cita-cli/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/driftluo%2Fcita-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272793018,"owners_count":24993830,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cita","cita-cli","rust"],"created_at":"2024-10-03T12:51:51.227Z","updated_at":"2025-08-30T02:04:59.580Z","avatar_url":"https://github.com/driftluo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cita-cli\n\n[![Build Status](https://travis-ci.org/cryptape/cita-cli.svg?branch=master)](https://travis-ci.org/cryptape/cita-cli)\n\n[English](./README.md) | 简体中文\n\nCITA CLI 是用于开发中调试 [CITA](https://github.com/cryptape/cita) 的命令行工具。\n\nCITA CLI 与 CITA 的关系，就像 redis-cli 和 redis。\n\n## 简介\n\n[cita-cli](./cita-cli): 命令行工具的实现。\n\n[cita-tool](./cita-tool): 用户可直接依赖cita-tool编写与CITA交互的程序。\n\n\u003e 本项目前提是用户需理解什么是智能合约。\n\n## 用户手册\n\n### 屏幕截图\n\n![A asciicast of cita-cli](./cita-cli.gif)\n\n### Clone and Build\n\n下载编译后的版本 [here](https://github.com/cryptape/cita-cli/releases)。\n如果需要最新版本，可编译源码，支持 Secp256k1/Ed25519/Sm2 加密算法:\n\n```bash\n$ git clone https://github.com/cryptape/cita-cli.git\n$ rustup update stable\n$ cd cita-cli/cita-cli\n$ cargo install --path .\n```\n会安装在 `~/.cargo/bin/cita-cli`。\n\n如果需要使用 `openssl` 去支持 https 请求， 确保 build 环境中存在 `openssl` 并按如下命令编译：\n\n```bash\n$ cd cita-cli/cita-cli\n$ cargo install --features openssl --path .\n```\n\n\u003e `rustls` 静态编译在 [release](https://github.com/cryptape/cita-cli/releases)，\n\u003e 并默认支持 https 请求。\n\n#### 编译 Linux 跨平台版本\n\n- 首先， 安装 `musl-gcc`， 默认在 `/usr/local/musl`\n\n```bash\n$ wget https://www.musl-libc.org/releases/musl-1.1.19.tar.gz\n$ tar -xzvf musl-1.1.19.tar.gz\n$ cd musl-1.1.19/\n$ ./configure \u0026\u0026 make \u0026\u0026 sudo make install\n$ sudo ln -sf /usr/local/musl/bin/musl-gcc /usr/local/bin/musl-gcc\n```\n\n- 第二， 添加 `x86_64-unknown-linux-musl` \n\n```bash\n$ rustup target add x86_64-unknown-linux-musl\n```\n\n- 第三， build\n\n```bash\n$ cargo install --target x86_64-unknown-linux-musl --path .\n```\n\n### 例子\n\n如果认为从命令行指定 URL 太复杂，可以直接编辑env文件，然后 cli 将获得相应的环境变量并自动执行。\n\n#### 交互模式（推荐）\n\n```bash\n$ cita-cli\n[       url        ]: http://121.196.200.225:1337\n[       pwd        ]: /home/luoc/Rust-work/cita-cli\n[      color       ]: true\n[      debug       ]: true\n[       json       ]: true\n[    encryption    ]: secp256k1\n[ completion_style ]: List\n[    edit_style    ]: Emacs\n[   save_private   ]: false\ncita\u003e switch --url http://121.196.200.225:1337\ncita\u003e rpc blockNumber\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": \"0x5fbb2\",\n  \"id\": 1\n}\ncita\u003e key create\n{\n  \"address\": \"0x1cd05e93e7501c125f14a4859c854fa6d0e63ad6\",\n  \"private\": \"0xfed11b78f963f7cf3de6fc43087900b13e449055e8a9bae1e9dc369412cdddca\",\n  \"public\": \"0xc10a38330fe144062d4a67e2de6f7eed5acf30da9dfd0fb0ecb86d05643afcc4a1b3b34b07731da088c2f564807049ba6632cb94dbcae81d1984ba248d5e5d1e\"\n}\ncita\u003e info\n[       url        ]: http://121.196.200.225:1337\n[       pwd        ]: /home/luoc/Rust-work/cita-cli\n[      color       ]: true\n[      debug       ]: true\n[       json       ]: true\n[    encryption    ]: secp256k1\n[ completion_style ]: List\n[    edit_style    ]: Emacs\n[   save_private   ]: false\ncita\u003e ethabi encode params --param uint256 16\n0000000000000000000000000000000000000000000000000000000000000010\ncita\u003e ethabi encode function --file ../HelloWorld.abi --name update --param 16\n82ab890a0000000000000000000000000000000000000000000000000000000000000010\ncita\u003e ethabi encode params --param address 08d1a8bbec3dbc2e4fa930dfb6886732f3a72aeb --param uint256 16\n\"00000000000000000000000008d1a8bbec3dbc2e4fa930dfb6886732f3a72aeb0000000000000000000000000000000000000000000000000000000000000010\"\ncita\u003e exit\n```\n\n#### 命令行模式\n\n\u003e Tips: 添加 `source \u003c(cita-cli completions bash)` 在你的 `.bashrc` 用来提供命令实现。\n\n- 获取链高度\n```bash\n$ cita-cli rpc blockNumber --url http://121.196.200.225:1337\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": \"0x1bc7f\",\n  \"id\": 1\n}\n```\n\n- 发送交易\n```bash\n$ cita-cli rpc sendRawTransaction \\\n    --private-key \"0x352416e1c910e413768c51390dfd791b414212b7b4fe6b1a18f58007fa894214\" \\\n    --code \"0x606060405234156100105760006000fd5b610015565b60e0806100236000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604b5780636d4ce63c14606c576045565b60006000fd5b341560565760006000fd5b606a60048080359060200190919050506093565b005b341560775760006000fd5b607d60a3565b6040518082815260200191505060405180910390f35b8060006000508190909055505b50565b6000600060005054905060b1565b905600a165627a7a72305820942223976c6dd48a3aa1d4749f45ad270915cfacd9c0bf3583c018d4c86f9da20029\" \\\n    --height 111146 \\\n    --url http://121.196.200.225:1337\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": {\n    \"status\": \"OK\",\n    \"hash\": \"0x16251c374ee87eae41cbd9203eea481b861738a19c19df9d3c6603b9fbe84478\"\n  },\n  \"id\": 2\n}\n```\n\n- 获取交易回执\n```bash\n$ cita-cli rpc getTransactionReceipt \\\n    --hash \"0x16251c374ee87eae41cbd9203eea481b861738a19c19df9d3c6603b9fbe84478\" \\\n    --url http://121.196.200.225:1337\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": {\n    \"transactionHash\": \"0x16251c374ee87eae41cbd9203eea481b861738a19c19df9d3c6603b9fbe84478\",\n    \"logs\": [],\n    \"blockNumber\": \"0x1b234\",\n    \"transactionIndex\": \"0x0\",\n    \"cumulativeGasUsed\": \"0xafc8\",\n    \"gasUsed\": \"0xafc8\",\n    \"blockHash\": \"0xca3733ac87fab23dc3c6c9b644631c98a937b369183c44f5743c5179587a3028\",\n    \"root\": null,\n    \"errorMessage\": null,\n    \"logsBloom\": \"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",\n    \"contractAddress\": \"0xd9ae0a3b3e856bf5d01061d99721cc4b136d7e26\"\n  },\n  \"id\": 1\n}\n```\n\n- 调用合约函数\n```bash\n$ cita-cli rpc sendRawTransaction \\\n    --private-key \"0x352416e1c910e413768c51390dfd791b414212b7b4fe6b1a18f58007fa894214\" \\\n    --address \"0x73552bc4e960a1d53013b40074569ea05b950b4d\" \\\n    --code \"0x60fe47b10000000000000000000000000000000000000000000000000000000000000001\" \\\n    --url http://121.196.200.225:1337\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": {\n    \"status\": \"OK\",\n    \"hash\": \"0x16001b0498c9b80133278a851859b859ada264d2928fd9b2bf0a1ba716079d23\"\n  },\n  \"id\": 2\n}\n```\n\n- 获取调用结果\n```bash\n$ cita-cli rpc call \\\n    --to 0xd9ae0a3b3e856bf5d01061d99721cc4b136d7e26 \\\n    --data 0x6d4ce63c \\\n    --height latest \\\n    --url http://121.196.200.225:1337\n{\n  \"jsonrpc\": \"2.0\",\n  \"result\": \"0x0000000000000000000000000000000000000000000000000000000000000001\",\n  \"id\": 1\n}\n```\n\n- 创建新的公私钥对\n```bash\n$ cita-cli key create\n{\n  \"address\": \"0x53ca05180d61bdc1c57b9c819c7545a87b1f3a1d\",\n  \"private\": \"0x49b7b71ce0120d727db74dde8cf7bec89626b5ff2f5c7522f4b8d4ffc878f2b7\",\n  \"public\": \"0xab7d29be188005a54d479a9971fba9faa7f28d637c83166f95de52f7f664b88ac9a3e7b570b462ec66702aac381da84021a52883f18ab1944df08f58db677982\"\n}\n```\n\n- 基于私钥生成公钥和地址\n```bash\n$ cita-cli key from-private --private-key 0x993ef0853d7bf1f4c2977457b50ea6b5f8bc2fd829e3ca3e19f6081ddabb07e9\n{\n  \"address\": \"0x9dcd6b234e2772c5451fd4ccf7582f4283140697\",\n  \"private\": \"0x993ef0853d7bf1f4c2977457b50ea6b5f8bc2fd829e3ca3e19f6081ddabb07e9\",\n  \"public\": \"0xa3cadf91b0ad021eb05eaa1fc2bb66109b3d004808c5cc2a1fb251a881aa12615394bde17dfaea4fb84372344d28a1bd2c4a9b4ab3f5d34ae524e2431ce494b6\"\n}\n```\n\n- 生成ABI\n```bash\n$ cita-cli ethabi encode params --param uint256 16\n0000000000000000000000000000000000000000000000000000000000000010\n$ cita-cli ethabi encode function --file ../HelloWorld.abi --name update --param 16\n82ab890a0000000000000000000000000000000000000000000000000000000000000010\n```\n\n## 贡献\n\n请提交在 [https://github.com/cryptape/cita-cli](https://github.com/cryptape/cita-cli)。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriftluo%2Fcita-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdriftluo%2Fcita-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdriftluo%2Fcita-cli/lists"}