{"id":13604025,"url":"https://github.com/usetech-llc/polkadot_api_cpp","last_synced_at":"2025-04-11T22:32:26.921Z","repository":{"id":103345038,"uuid":"189715716","full_name":"usetech-llc/polkadot_api_cpp","owner":"usetech-llc","description":"С++ API for Polkadot. ","archived":false,"fork":false,"pushed_at":"2023-09-04T14:12:00.000Z","size":1942,"stargazers_count":17,"open_issues_count":12,"forks_count":21,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-01-25T03:42:25.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/usetech-llc.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-06-01T09:43:43.000Z","updated_at":"2024-04-15T00:40:42.308Z","dependencies_parsed_at":"2024-04-15T00:40:39.350Z","dependency_job_id":"1d882d37-6426-478f-950a-1d32f8eb0b34","html_url":"https://github.com/usetech-llc/polkadot_api_cpp","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/usetech-llc%2Fpolkadot_api_cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usetech-llc%2Fpolkadot_api_cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usetech-llc%2Fpolkadot_api_cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/usetech-llc%2Fpolkadot_api_cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/usetech-llc","download_url":"https://codeload.github.com/usetech-llc/polkadot_api_cpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248489838,"owners_count":21112651,"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-08-01T19:00:38.405Z","updated_at":"2025-04-11T22:32:23.316Z","avatar_url":"https://github.com/usetech-llc.png","language":"C++","funding_links":[],"categories":["Libraries","Client Libraries"],"sub_categories":["Multisig Wallets"],"readme":"# Polkadot Substrate C++ API\n\n## Install Prerequisites\n\n### Boost\n```\nsudo apt-get install libboost-all-dev\n```\n\n### Build tools\n```\nsudo apt-get -y install build-essential cmake\n```\n\n### curl headers\n```\nsudo apt-get install libcurl4-openssl-dev\n```\n\n### doxygen\n```\nsudo apt-get install doxygen python-pydot python-pydot-ng graphviz\n```\n\n### Other dependencies: websocketpp, sr25519-crust...\nNote that we are using c8df32 commit of sr25519 library, which is the last \"verified\" at the moment. The most recent commit was breaking signature test. \n```\nmake deps\n```\n\n## Installation\n\n### Installation from deb package\n\nDownload PolkadotCppAPI-0.1.1-Linux.deb from release files attached to this release and run\n```\nsudo dpkg -i PolkadotCppAPI-0.1.1-Linux.deb\n```\n\n### Manual installation (linux)\n\nDownload polkacpp.tar.gz from release files attached to this release and copy all files to the system root preserving directory structure from the archive.\n\n### Building\n```\ngit clone https://github.com/usetech-llc/polkadot_api_cpp\ncd polkadot_api_cpp\ncmake .\nmake\nsudo make install\n```\n\n### Build \"clip\" example client\n```\nmake clip\n```\n\n### Run connect basic example\n\nConnect example will establish WebSocket connection to the polkadot node and read and output basic information.\n```\nbin/clip connect\n```\n\n### Read Address Balance Example\n\nBalance example will establish WebSocket connection and read and output address balance in DOTs.\n```\nbin/clip balance \u003cyour polkadot address\u003e\n```\n\n### Transfer DOTs Example\n\n```\ntrasnfer \u003cfrom address\u003e \u003cto address\u003e \u003camount\u003e \u003cprivate key file\u003e\n```\n\n## Running Unit Tests\n\n```\nmake test\n```\n\n## How to Use\n\n### Files to include\n```\n#include \u003cpolkadotcpp/polkadot.h\u003e\n```\n\n### Files to link\n```\n/usr/lib/polkadotcpp/libpolkacpp.a\n```\n\n### Library Initialization\nParity node URL is the only required parameter, though URL must include port. Example:\n```\nauto api = polkadot::api::getInstance()-\u003eapp();\n```\n\n### Establishing and maintaining connection\nThis call will establish connection and start message thread. It will also ping the node several times per minute with \"health\" request to keep the connection alive.\n```\napi-\u003econnect(\"wss://poc3-rpc.polkadot.io:443/\");\n```\n\n### Reading data from polkadot node\nThe data is returned as C structures. This example shows how to read (and output) system info:\n```\nauto systemInfo = api-\u003egetSystemInfo();\n\ncout \u003c\u003c \"  Chain ID       : \" \u003c\u003c systemInfo-\u003echainId \u003c\u003c endl\n     \u003c\u003c \"  Chain Name     : \" \u003c\u003c systemInfo-\u003echainName \u003c\u003c endl\n     \u003c\u003c \"  Token Decimals : \" \u003c\u003c systemInfo-\u003etokenDecimals \u003c\u003c endl\n     \u003c\u003c \"  Token Symbol   : \" \u003c\u003c systemInfo-\u003etokenSymbol \u003c\u003c endl;\n```\n\n### Subscribing for updates\n\nSubscribing is done by calling a matching subscribe method with parameters (if needed) and a callback (or a lambda function). This example subscribes for balance updates and prints new balance when it arrives:\n```\napi-\u003esubscribeBalance(address, [\u0026](uint128 balance) {\n    cout \u003c\u003c endl \u003c\u003c \"  Balance: \" \u003c\u003c (uint64_t)balance \u003c\u003c endl \u003c\u003c endl;\n});\n```\n\nIn order to stop subscription, call matching unsubsribe method:\n```\napi-\u003eunsubscribeBalance();\n```\n\n### Sending transactions (signed Extrinsics)\n\nThis example sends some DOTs between addresses and waits for execution. Transaction is signed with private key.\n```\napi-\u003esignAndSendTransfer(senderAddr, senderPrivateKeyStr, recipientAddr, amount, [\u0026](string result) {\n    if (result == \"ready\")\n        cout \u003c\u003c endl \u003c\u003c endl \u003c\u003c \"   ---=== Transaction was registered in network ===--- \" \u003c\u003c endl \u003c\u003c endl \u003c\u003c endl;\n    if (result == \"finalized\") {\n        cout \u003c\u003c endl \u003c\u003c endl \u003c\u003c \"   ---=== Transaction was mined! ===--- \" \u003c\u003c endl \u003c\u003c endl \u003c\u003c endl;\n        done = true;\n    }\n});\n```\n\n### Finishing work\n\nWhen connection is not needed anymore, call\n```\napi-\u003edisconnect();\n```\n\n### More Information\n\nThe complete documentation of API interface can be found at this starting point:\nhttps://htmlpreview.github.io/?https://github.com/usetech-llc/polkadot_api_cpp/blob/master/doc/html/classIApplication.html\n\nFor more examples see:\n- [examples](https://github.com/usetech-llc/polkadot_api_cpp/tree/master/examples) folder,\n- [test](https://github.com/usetech-llc/polkadot_api_cpp/tree/master/test) folder with unit and E2E tests,\n- [polkadot_ui](https://github.com/usetech-llc/polkadot_ui) repository, which implements a GTK 3.0 UI and uses this API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusetech-llc%2Fpolkadot_api_cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fusetech-llc%2Fpolkadot_api_cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fusetech-llc%2Fpolkadot_api_cpp/lists"}