{"id":13523621,"url":"https://github.com/ic4j/ic4j-agent","last_synced_at":"2026-01-14T03:38:02.103Z","repository":{"id":57992658,"uuid":"448150950","full_name":"ic4j/ic4j-agent","owner":"ic4j","description":"IC4J Agent for the Internet Computer","archived":false,"fork":false,"pushed_at":"2025-05-21T17:32:54.000Z","size":312,"stargazers_count":21,"open_issues_count":4,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-21T18:47:25.996Z","etag":null,"topics":["android","dfinity","icp","java"],"latest_commit_sha":null,"homepage":"","language":"Java","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/ic4j.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,"publiccode":null,"codemeta":null}},"created_at":"2022-01-15T01:14:42.000Z","updated_at":"2025-05-21T17:32:58.000Z","dependencies_parsed_at":"2024-04-17T18:40:53.528Z","dependency_job_id":"9703acea-7643-43e5-a45e-1ed460ba26e8","html_url":"https://github.com/ic4j/ic4j-agent","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ic4j/ic4j-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ic4j","download_url":"https://codeload.github.com/ic4j/ic4j-agent/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ic4j%2Fic4j-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["android","dfinity","icp","java"],"created_at":"2024-08-01T06:01:01.909Z","updated_at":"2026-01-14T03:38:02.095Z","avatar_url":"https://github.com/ic4j.png","language":"Java","funding_links":[],"categories":["Client Libraries (Agents)","CDK\u0026Agent"],"sub_categories":["Java/Kotlin"],"readme":"# dfinity-agent\nRead complete documentation here \u003ca href=\"https://docs.ic4j.com\"\u003e\nhttps://docs.ic4j.com\u003c/a\u003e.\n\nIC4J Java open source libraries provide a range of tools and interfaces for Java developers to interact with the Internet Computer network and build decentralized applications on top of it.\n\n\u003ca href=\"https://dfinity.org/\"\u003e\nhttps://dfinity.org/\n\u003c/a\u003e\n\nThe code is implementation of the Internet Computer Interface protocol \n\n\u003ca href=\"https://sdk.dfinity.org/docs/interface-spec/index.html\"\u003e\nhttps://sdk.dfinity.org/docs/interface-spec/index.html\n\u003c/a\u003e\n\nand it's using Dfinity Rust agent as an inspiration, using similar package structures and naming conventions.\n\n\u003ca href=\"https://github.com/dfinity/agent-rs\"\u003e\nhttps://github.com/dfinity/agent-rs\n\u003c/a\u003e\n\n\n# License\n\nIC4J Agent is available under Apache License 2.0.\n\n# Documentation\n\n## Supported type mapping between Java and Candid\n\n| Candid      | Java    |\n| :---------- | :---------- | \n| bool   | Boolean | \n| int| BigInteger   | \n| int8   | Byte | \n| int16   | Short | \n| int32   | Integer | \n| int64   | Long | \n| nat| BigInteger   | \n| nat8   | Byte | \n| nat16   | Short | \n| nat32   | Integer | \n| nat64   | Long |\n| float32   | Float | \n| float64   | Double | \n| text   | String | \n| opt   | Optional | \n| principal   | Principal | \n| vec   | array, List | \n| record   | Map, Class | \n| variant   | Map, Enum | \n| func   | Func | \n| service   | Service | \n| null   |Null | \n\n## Supported Identities\n\nAnonymous\nImplicit by default\n\n### Basic Identity (Ed25519)\n\nEither generate Key Pair\n\n```\nKeyPair keyPair = KeyPairGenerator.getInstance(\"Ed25519\").generateKeyPair();\n\nIdentity identity = BasicIdentity.fromKeyPair(keyPair);\n```\n\nOr use PEM file\n\n```\nIdentity identity = BasicIdentity.fromPEMFile(path);\n```\n\n### Secp256k1 Identity\n\nGet Key Pair from PEM file\n\n```\nIdentity identity = Secp256k1Identity.fromPEMFile(path);\n```\n\nFor Basic and Identities we are using Bouncy Castle open source libraries. To add it to your Java code you can use this code\n\n```\nSecurity.addProvider(new BouncyCastleProvider());\n```\n\n## Supported Transports\n\n### HTTP Transport\n\n```\nReplicaTransport transport = ReplicaApacheHttpTransport.create(\"http://localhost:8000\");\n```\nor for Android\n\n```\nReplicaTransport transport = ReplicaOkHttpTransport.create(\"http://localhost:8000\");\n```\n\n## Agent Class\n\nCreate Agent object\n\n```\nAgent agent = new AgentBuilder().transport(transport).identity(identity).build();\n```\n\n## IDLArgs\n\nTo pass arguments to the Internet Computer Canister methods\n\n```\nList\u003cIDLValue\u003e args = new ArrayList\u003cIDLValue\u003e();\n\nBigInteger intValue =new BigInteger(\"10000\");\n\t\t\t\nargs.add(IDLValue.create(intValue));\t\t\t\n\t\t\t\nIDLArgs idlArgs = IDLArgs.create(args);\n\nbyte[] buf = idlArgs.toBytes();\n```\n\n## Supported Raw Methods\n\n### Query\n\nTo call query method\n\n```\nCompletableFuture\u003cbyte[]\u003e response = agent.queryRaw(Principal.fromString(canister_id),\n\t\t\t\t\tPrincipal.fromString(canister_id), \"echoInt\", buf, ingressExpiryDatetime);\n\nbyte[] output = response.get();\nIDLArgs outArgs = IDLArgs.fromBytes(output);\n```\n\n### Update\n\nTo call update method\n\n```\nCompletableFuture\u003cRequestId\u003e response = agent.updateRaw(Principal.fromString(canister_id),\n\t\t\t\t\tPrincipal.fromString(canister_id), \"greet\", buf, ingressExpiryDatetime);\n```\n\n### GetState\n\nTo call getState method to retrieve result of update method\n\n```\nRequestId requestId = response.get();\n\nCompletableFuture\u003cRequestStatusResponse\u003e statusResponse = agent.requestStatusRaw(requestId,\n\t\tPrincipal.fromString(canister_id));\n```\n\n## Supported Builders\n\n### QueryBuilder\n\n```\nCompletableFuture\u003cbyte[]\u003e response = QueryBuilder.create(agent, Principal.fromString(canister_id), \"echoInt\").expireAfter(Duration.ofMinutes(3)).arg(buf).call();\n\nbyte[] output = response.get();\nIDLArgs outArgs = IDLArgs.fromBytes(output);\n```\n\n### UpdateBuilder\n\n```\nUpdateBuilder updateBuilder = UpdateBuilder\n\t.create(agent, Principal.fromString(canister_id), \"greet\").arg(buf);\n\t\n\t\t\t\t\tCompletableFuture\u003cbyte[]\u003e builderResponse = updateBuilder.callAndWait(com.scaleton.dfinity.agent.Waiter.create(60, 5));\n\t\t\t\t\t\nbyte[] output = builderResponse.get();\nIDLArgs outArgs = IDLArgs.fromBytes(output);\t\n```\n\n## Dynamic Proxy with annotated facade interface\n\nAdditionally you can also use Dynamic Proxy Class with facade Java interface that maps methods in the Internet Computer Canister. Agent values can be replaced with Agent Java object  \n\n```\n@Agent(identity = @Identity(type = IdentityType.BASIC, pem_file = \"./src/test/resources/Ed25519_identity.pem\"), transport = @Transport(url = \"http://localhost:8001\"))\n@Canister(\"rrkah-fqaaa-aaaaa-aaaaq-cai\")\n@EffectiveCanister(\"rrkah-fqaaa-aaaaa-aaaaq-cai\")\npublic interface HelloProxy {\n\t\n\t@QUERY\n\tpublic String peek(@Argument(Type.TEXT)String name, @Argument(Type.INT) BigInteger value);\n\t\n\t@QUERY\n\t@Name(\"echoInt\")\n\tpublic BigInteger getInt(BigInteger value);\t\n\t\n\t@QUERY\n\tpublic CompletableFuture\u003cDouble\u003e getFloat(Double value);\n\t\n\t@UPDATE\n\t@Name(\"greet\")\n\t@Waiter(timeout = 30)\n\tpublic CompletableFuture\u003cString\u003e greet(@Argument(Type.TEXT)String name);\n\n}\n```\n\nThen create Dynamic Proxy object and call the method\n\n```\nHelloProxy hello = ProxyBuilder.create().getProxy(HelloProxy.class);\n\t\t\t\nString result = hello.peek(value, intValue);\n```\n\nUse Dynamic Proxy with POJO Java Object mapped to Candid RECORD type\n\nPOJO Java class with Candid annotations\n\n```\nimport java.math.BigInteger;\n\nimport org.ic4j.candid.annotations.Field;\nimport org.ic4j.candid.annotations.Name;\nimport org.ic4j.candid.types.Type;\n\npublic class Pojo {\n\t@Field(Type.BOOL)\n\t@Name(\"bar\")\n\tpublic Boolean bar;\n\n\t@Field(Type.INT)\n\t@Name(\"foo\")\n\tpublic BigInteger foo;\n}\n```\n\n```\nPojo pojoValue = new Pojo();\n\t\t\t\t\npojoValue.bar = new Boolean(false);\npojoValue.foo = BigInteger.valueOf(43); \n\t\t\t\t\nPojo pojoResult = hello.getPojo(pojoValue);\n```\n\n## JSON (Jackson) serialization and deserialization\n\nUse JacksonSerializer to serialize Jackson JsonNode or Jackson compatible Pojo class to Candid\n\n```\nJsonNode jsonValue;\nIDLType idlType;\n\nIDLValue idlValue = IDLValue.create(jsonValue, JacksonSerializer.create(idlType));\nList\u003cIDLValue\u003e args = new ArrayList\u003cIDLValue\u003e();\nargs.add(idlValue);\n\nIDLArgs idlArgs = IDLArgs.create(args);\n\nbyte[] buf = idlArgs.toBytes();\n```\n\nUse JacksonDeserializer to deserialize Candid to Jackson JsonNode or Jackson compatible Pojo class\n\n```\nJsonNode jsonResult = IDLArgs.fromBytes(buf).getArgs().get(0)\n\t.getValue(JacksonDeserializer.create(idlValue.getIDLType()), JsonNode.class);\n```\n\n## XML (DOM) serialization and deserialization\n\nUse DOMSerializer to serialize DOM Node to Candid\n\n```\nNode domValue;\n\nIDLValue idlValue = IDLValue.create(domValue,DOMSerializer.create());\nList\u003cIDLValue\u003e args = new ArrayList\u003cIDLValue\u003e();\nargs.add(idlValue);\n\nIDLArgs idlArgs = IDLArgs.create(args);\n\nbyte[] buf = idlArgs.toBytes();\n```\n\nUse DOMDeserializer to deserialize Candid to DOM Node\n\n```\nDOMDeserializer domDeserializer = DOMDeserializer.create(idlValue.getIDLType()).rootElement(\"http://scaleton.com/dfinity/candid\",\"data\");\n\t\t\t\nNode domResult = IDLArgs.fromBytes(buf).getArgs().get(0).getValue(domDeserializer, Node.class);\n```\n\n## JDBC (ResultSet) serialization\n\nUse JDBCSerializer to serialize JDBC ResultSet to Candid\n\n```\nResultSet result = statement.executeQuery(sql);\n\t\t\t\nIDLValue idlValue = IDLValue.create(result, JDBCSerializer.create());\nList\u003cIDLValue\u003e args = new ArrayList\u003cIDLValue\u003e();\nargs.add(idlValue);\n\nIDLArgs idlArgs = IDLArgs.create(args);\n\nbyte[] buf = idlArgs.toBytes();\n```\n\n\n# Downloads / Accessing Binaries\n\nTo add IC4J Agent library to your Java project use Maven or Gradle import from Maven Central.\n\n\u003ca href=\"https://search.maven.org/artifact/org.ic4j/ic4j-agent/0.7.5/jar\"\u003e\nhttps://search.maven.org/artifact/org.ic4j/ic4j-agent/0.7.5/jar\n\u003c/a\u003e\n\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.ic4j\u003c/groupId\u003e\n  \u003cartifactId\u003eic4j-agent\u003c/artifactId\u003e\n  \u003cversion\u003e0.7.5\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.ic4j\u003c/groupId\u003e\n  \u003cartifactId\u003eic4j-candid\u003c/artifactId\u003e\n  \u003cversion\u003e0.7.5\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n```\nimplementation 'org.ic4j:ic4j-agent:0.7.5'\nimplementation 'org.ic4j:ic4j-candid:0.7.5'\n```\n\n\n## Dependencies\n\nThis this is using these open source libraries\n\n### Apache HTTP Client V5\nTo provide HTTP POST and GET operations.\n\n### Ok HTTP Client \nTo provide HTTP POST and GET operations for Android.\n\n### Jackson CBOR Serializer and Deserializer\nTo manage CBOR payloads.\n\n### Bouncy Castle Cryptography Libraries\nTo manage Ed25519 and Secp256k1 signatures.\n\n### Bouncy Castle Cryptography Libraries\nTo manage Ed25519 and Secp256k1 signatures.\n\n### MIRACL Core Cryptographic Library\nTo manage BLS12381 algorithm. \n\n\n# Build\n\nYou need JDK 8+ to build Dfinity Agent.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fic4j%2Fic4j-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fic4j%2Fic4j-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fic4j%2Fic4j-agent/lists"}