{"id":13523606,"url":"https://github.com/Zondax/icp-client-cpp","last_synced_at":"2025-04-01T01:33:06.332Z","repository":{"id":156288150,"uuid":"610371997","full_name":"Zondax/icp-client-cpp","owner":"Zondax","description":"Internet Computer - Client C/C++","archived":false,"fork":false,"pushed_at":"2025-03-18T15:46:11.000Z","size":426,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-23T22:11:55.497Z","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/Zondax.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}},"created_at":"2023-03-06T16:33:12.000Z","updated_at":"2025-03-18T15:46:15.000Z","dependencies_parsed_at":"2024-01-13T22:45:37.923Z","dependency_job_id":null,"html_url":"https://github.com/Zondax/icp-client-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zondax%2Ficp-client-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zondax%2Ficp-client-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zondax%2Ficp-client-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zondax%2Ficp-client-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zondax","download_url":"https://codeload.github.com/Zondax/icp-client-cpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246567084,"owners_count":20798110,"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-01T06:01:01.762Z","updated_at":"2025-04-01T01:33:02.179Z","avatar_url":"https://github.com/Zondax.png","language":"C++","funding_links":[],"categories":["Client Libraries (Agents)"],"sub_categories":["C++"],"readme":"# IC-C\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![GithubActions](https://github.com/zondax/icp-client-cpp/actions/workflows/build.yml/badge.svg)](https://github.com/Zondax/icp-client-cpp/blob/main/.github/workflows/build.yaml)\n\n---\n\n![zondax_light](docs/zondax_light.png#gh-light-mode-only)\n![zondax_dark](docs/zondax_dark.png#gh-dark-mode-only)\n\n_Please visit our website at [zondax.ch](https://www.zondax.ch)_\n\n---\n\n## General Description\n\nThe objective of this project is to provide a C and C++ interface for the Rust Agent Crate\n\nReference: https://internetcomputer.org/docs/current/developer-docs/agents/\n\nWhat an agent does:\n\n- Encodes arguments to be sent in REST calls (Candid based)\n- Verifies certificates and decode responses\n- Manages authentication\n\n### Disclaimer\nTeam is currently working on building the project and running it on Windows platforms.\n\n### Project Build and Description\n\nConfigure Project and generate makefile.\n\n    mkdir build\n    cd build\n    cmake ..\n    make\n\nAfter compilation, the library offers three primary functionalities:\n\n- C Wrapper for the agent: A static library (libagent_c.a) that provides a C wrapper for the agent.\n- C++ Interface for the agent  (libagent_cpp.a) : Another static library that uses the C wrapper to provide a C++ interface for the agent.\n- Cpp Header File Generator from Candid File: This feature simplifies developer interaction with a canister by generating an hpp file from the canister candid file. This eliminates the need to handle candid types directly.\nAll candid services are translated into C++ functions using native C++ types, allowing them to be called with the C++ interface. This makes it more convenient for developers to work with the library and interact with canisters.\n\nTo use the generator:\n\n    cd ic-agent-wrapper\n    cargo run -p generate-cpp {did file} {canister name}\n\nThe hpp file can be found on the root of the project inside\n/src/declarations/{canister_name}/.\n\n### Guidance \u0026 Core Testing \n\nThe testing framework [doctest](https://github.com/doctest/doctest/tree/master) is used for unit testing different functionality exported by this library.\nThe tests can be compiled by running:\n```\nmake tests \n```\nThis command will generate a new ***test*** binary which can be executed:\n\n```\n./test\n\n```\nThe framework will run all the tests and generate a report similar to the one bellow:\n```\n╰─ ./test                                                                                                                                                        ─╯\n[doctest] doctest version is \"2.4.11\"\n[doctest] run with \"--help\" for options\n===============================================================================\n[doctest] test cases:  8 |  8 passed | 0 failed | 0 skipped\n[doctest] assertions: 20 | 20 passed | 0 failed |\n[doctest] Status: SUCCESS!\n```\nYou can list the different available tests in the library by running:\n```\n./test -ltc \n```\nThe output at the moment of writing is: \n```\n╰─ ./test -ltc                                                                                                                                                   ─╯\n[doctest] listing all test case names\n===============================================================================\nIdentity_from_pem\nAnonymous Identity\nTesting Anonymous Principal\nTesting Anonymous Principal from/to text\nPrincipal from bytes\nPrincipal from bytes should fail\nPrincipal SelfAuthenticating\nPrincipal management\n===============================================================================\n[doctest] unskipped test cases passing the current filters: 8\n```\nPlease refer to doctest documentation and available options.\n\nOn the examples folders it can be found different usage examples and\ntesting examples for the core exposed functions. All the examples are compiled with the projects and the executables can be found on hte build/ folder. The main examples that can be used as guidance are:\n\n- examples/hello_c : interaction with a canister using c wrapper, requires deploying a local hello world canister (see more below);\n\n- examples-cpp/hello : interaction with a canister using Cpp interface, canister header file already generated requires deploying a local hello world canister (see more below);\n\n- examples/ic_c : interaction with IC canister using c wrapper.\n\n- examples-cpp/ic : interaction with a canister using Cpp interface, canister header file already generated.\n\n\n### How to use\n\nTo use this library in a project you can clone this source code into your project and build the library with:\n\n    mkdir build\n    cd build\n    cmake ..\n    make\n\nCreate the header file for the canister:\n\n    cd ic-agent-wrapper\n    cargo run -p generate-cpp ../rust_hello_backend.did  rust_hello\n\nTake as an example a simple hello world project with the following structure:\n\n    ── hello_world\n        ├── CMakeLists.txt\n        ├── icp-client-cpp\n        └── src\n            └── main.cpp\n        └── inc\n            ├── rust_hello_backend.did\n            └── rust_hello.hpp\n        \n\nThen link the rust wrapper library, ic_agent_wrapper, and the c library, agent-c.\nFor a CMake platform, the Cmakelists file would look like this:\n\n    # OS-specific libraries\n    if(APPLE)\n        find_library(SECURITY_LIB Security)\n        find_library(COREFOUNDATION_LIB CoreFoundation)\n        set(EXTRA_LIBS ${SECURITY_LIB} ${COREFOUNDATION_LIB})\n    elseif(UNIX AND NOT APPLE)\n        set(EXTRA_LIBS m)\n    elseif(WIN32)\n        # Add any Windows-specific libraries here\n    endif()\n\n    # Link against the icp-client-cpp libraries\n    link_directories(icp-client-cpp/build)\n    link_directories(icp-client-cpp/ic-agent-wrapper/target/release/)\n\n    add_executable(helloworld src/main.c)\n\n    # Specify libraries  to use when linking\n    target_link_libraries(helloworld agent_cpp agent_c ic_agent_wrapper ${EXTRA_LIBS})\n    # Include deirectories with .h files\n    target_include_directories(helloworld PRIVATE \"inc\")\n    target_include_directories(helloworld PRIVATE \"icp-client-cpp/lib-agent-cpp/inc\")\n    target_include_directories(helloworld PRIVATE \"icp-client-cpp/lib-agent-c/inc\")\n\n#### Deploy local Hello world canister\n\nIn a separate directory create new hello world canister:\n\n    dfx new --type=rust rust_hello\n\nChange to your project directory:\n\n    cd rust_hello\n\nStart the local execution environment:\n\n    dfx start --background\n\nRegister, build, and deploy the canister:\n\n    dfx deploy\n\n### Rust agent crate\n\n- Repository: https://github.com/dfinity/agent-rs\n- Documentation: https://docs.rs/ic-agent/latest/ic_agent/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZondax%2Ficp-client-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZondax%2Ficp-client-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZondax%2Ficp-client-cpp/lists"}