https://github.com/ic4j/ic4j-management
IC4J Management Service
https://github.com/ic4j/ic4j-management
dfinity internet-computer java
Last synced: 5 months ago
JSON representation
IC4J Management Service
- Host: GitHub
- URL: https://github.com/ic4j/ic4j-management
- Owner: ic4j
- License: apache-2.0
- Created: 2022-06-24T15:27:09.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2025-05-25T20:22:32.000Z (about 1 year ago)
- Last Synced: 2025-05-25T21:28:23.673Z (about 1 year ago)
- Topics: dfinity, internet-computer, java
- Language: Java
- Homepage:
- Size: 205 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## IC4J Management Java Service
This Java library is an implementation of Dfinity's Virtual Canister Management API and directly communicates with the Management Virtual Canister.
https://internetcomputer.org/docs/current/references/ic-interface-spec#ic-management-canister
Developers can utilize this library within any Java application to perform various operations, such as creating, deleting, starting, and stopping a canister, installing, uninstalling, and reinstalling WASM canister code, updating canister settings, and adding additional funds to a canister.
To test Management Service locally, install local Internet Computer instance. Then just configure custom Java properties with management.location value pointing to the local instance and management.identity pointing to identity PEM file.
To use Management Service create ManagementService object. Define your own properties if you want to use local instance of the service.
```
Identity identity = BasicIdentity.fromPEMFile(sourceReader);
Agent agent = new AgentBuilder().transport(transport)
.identity(identity)
.build();
ManagementService managementService = ManagementService.create(agent);
```
Then call Management Service methods.
```
Principal canisterId = managementService.provisionalCreateCanisterWithCycles(Optional.empty(), Optional.empty()).get();
LOG.info(canisterId.toString());
Path path = Paths.get(getClass().getClassLoader().getResource(WASM_FILE).getPath());
byte [] wasmModule = Files.readAllBytes(path);
managementService.installCode(canisterId, Mode.install, wasmModule, ArrayUtils.EMPTY_BYTE_ARRAY);
CanisterStatusResponse canisterStatusResponse = managementService.canisterStatus(canisterId).get();
LOG.info(canisterStatusResponse.status.name());
managementService.stopCanister(canisterId);
canisterStatusResponse = managementService.canisterStatus(canisterId).get();
LOG.info(canisterStatusResponse.status.name());
managementService.uninstallCode(canisterId);
managementService.deleteCanister(canisterId);
```
# Downloads / Accessing Binaries
To add Java IC4J Management Service library to your Java project use Maven or Gradle import from Maven Central.
https://search.maven.org/artifact/ic4j/ic4j-management/0.7.5/jar
```
org.ic4j
ic4j-management
0.7.5
```
```
implementation 'org.ic4j:ic4j-management:0.7.5'
```
# Build
You need JDK 8+ to build IC4J Management Service.