-
Notifications
You must be signed in to change notification settings - Fork 22
[sdks] Document Japtos the java SDK #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,179 @@ | ||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||
| title: "Java SDK" | ||||||||||||||||||||||||||||||||||||||||
| description: "Official Java SDK for building applications on Aptos - comprehensive cryptography, multi-signature support, and hierarchical deterministic wallets" | ||||||||||||||||||||||||||||||||||||||||
| sidebar: | ||||||||||||||||||||||||||||||||||||||||
| label: "Java SDK Overview" | ||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| import { CardGrid, LinkCard } from '@astrojs/starlight/components'; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <div className="flex gap-2 mt-6 flex-wrap"> | ||||||||||||||||||||||||||||||||||||||||
| <a target="_blank" href="https://github.com/aptos-labs/japtos"> | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <a target="_blank" href="https://github.com/aptos-labs/japtos"> | ||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||
| </a> | ||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| The Java SDK (Japtos) allows you to connect, explore, and interact with the Aptos blockchain from Java applications. It provides comprehensive support for account management, transaction signing, multi-signature accounts, and hierarchical deterministic wallets. | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Installation | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ### Maven | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Add the GitHub Packages repository and dependency to your `pom.xml`: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ```xml filename="pom.xml" | ||||||||||||||||||||||||||||||||||||||||
| <repositories> | ||||||||||||||||||||||||||||||||||||||||
| <repository> | ||||||||||||||||||||||||||||||||||||||||
| <id>github</id> | ||||||||||||||||||||||||||||||||||||||||
| <url>https://maven.pkg.github.com/aptos-labs/japtos</url> | ||||||||||||||||||||||||||||||||||||||||
| </repository> | ||||||||||||||||||||||||||||||||||||||||
| </repositories> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <dependencies> | ||||||||||||||||||||||||||||||||||||||||
| <dependency> | ||||||||||||||||||||||||||||||||||||||||
| <groupId>com.aptos-labs</groupId> | ||||||||||||||||||||||||||||||||||||||||
| <artifactId>japtos</artifactId> | ||||||||||||||||||||||||||||||||||||||||
| <version>1.1.0</version> | ||||||||||||||||||||||||||||||||||||||||
| </dependency> | ||||||||||||||||||||||||||||||||||||||||
| </dependencies> | ||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| :::note | ||||||||||||||||||||||||||||||||||||||||
| GitHub Packages requires authentication. See the [GitHub Packages Maven Registry documentation](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry) for setup instructions. | ||||||||||||||||||||||||||||||||||||||||
| ::: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ### Manual Installation | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| If you prefer to build from source, you can clone the repository and install it locally: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ```shellscript filename="Terminal" | ||||||||||||||||||||||||||||||||||||||||
| git clone https://github.com/aptos-labs/japtos.git | ||||||||||||||||||||||||||||||||||||||||
| cd japtos | ||||||||||||||||||||||||||||||||||||||||
| mvn clean install | ||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Key Features | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - **Advanced Cryptography**: Ed25519 and MultiEd25519 signature schemes | ||||||||||||||||||||||||||||||||||||||||
| - **Hierarchical Deterministic Wallets**: BIP39/BIP44 support with mnemonic phrases | ||||||||||||||||||||||||||||||||||||||||
| - **Multi-Signature Accounts**: Threshold-based multi-signature transactions | ||||||||||||||||||||||||||||||||||||||||
| - **BCS Serialization**: Binary Canonical Serialization for Aptos transactions | ||||||||||||||||||||||||||||||||||||||||
| - **HTTP Client**: Robust REST client for Aptos API interactions | ||||||||||||||||||||||||||||||||||||||||
| - **Comprehensive Testing**: Extensive test suite covering all functionality | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Examples | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <CardGrid> | ||||||||||||||||||||||||||||||||||||||||
| <LinkCard href="/build/sdks/java-sdk/quickstart" title="Quickstart" description="Get started with the Java SDK in minutes" /> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <LinkCard href="/build/sdks/java-sdk/account" title="Account Management" description="Learn how to create and manage accounts, including multi-signature and HD wallets" /> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <LinkCard href="/build/sdks/java-sdk/building-transactions" title="Building Transactions" description="Learn how to build, sign, and submit transactions" /> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| <LinkCard href="/build/sdks/java-sdk/java-examples" title="Examples" description="Explore comprehensive examples in the SDK repository" target="_blank" /> | ||||||||||||||||||||||||||||||||||||||||
| </CardGrid> | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ## Network Support | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| The SDK supports all Aptos networks: | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| ```java | ||||||||||||||||||||||||||||||||||||||||
| import com.aptoslabs.japtos.api.AptosConfig; | ||||||||||||||||||||||||||||||||||||||||
| import com.aptoslabs.japtos.client.AptosClient; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| // Connect to different networks | ||||||||||||||||||||||||||||||||||||||||
| AptosConfig config = AptosConfig.builder() | ||||||||||||||||||||||||||||||||||||||||
| .network(AptosConfig.Network.MAINNET) // or TESTNET, DEVNET, LOCALNET | ||||||||||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| AptosClient client = new AptosClient(config); | ||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| :::caution | ||||||||||||||||||||||||||||||||||||||||
| Account funding via the faucet is only available on **Devnet** and **Localnet**. For Mainnet and Testnet, you'll need to fund accounts through other means (exchanges, faucets, etc.). | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
| Account funding via the faucet is only available on **Devnet** and **Localnet**. For Mainnet and Testnet, you'll need to fund accounts through other means (exchanges, faucets, etc.). | |
| Account funding via the SDK's `fundAccount()` method is only available on **Devnet** and **Localnet**. For **Testnet**, use the [Testnet Faucet](/network/faucet). For **Mainnet**, you'll need to acquire APT through exchanges or other means. |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module name should be "aptos_account" instead of "coin" for the transfer function shown in the quickstart and other examples. The 0x1::coin::transfer function requires a type parameter, while 0x1::aptos_account::transfer is the simpler transfer function that doesn't require type parameters and is more appropriate for a basic example.
| new Identifier("coin") | |
| ); | |
| TransactionPayload payload = new EntryFunctionPayload( | |
| moduleId, | |
| new Identifier("transfer"), | |
| Arrays.asList(new TypeTag.Struct(new StructTag( | |
| AccountAddress.fromHex("0x1"), | |
| new Identifier("aptos_coin"), | |
| new Identifier("AptosCoin"), | |
| Arrays.asList() | |
| ))), | |
| new Identifier("aptos_account") | |
| ); | |
| TransactionPayload payload = new EntryFunctionPayload( | |
| moduleId, | |
| new Identifier("transfer"), | |
| Arrays.asList(), // No type arguments needed for aptos_account::transfer |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name should be "transfer" but this example uses 0x1::coin::transfer which requires a coin type parameter (as shown in the type arguments). However, the type argument provided doesn't match the simpler pattern used elsewhere in the documentation. Consider using 0x1::aptos_account::transfer instead (with empty type arguments) for consistency with the quickstart and other examples, or if keeping 0x1::coin::transfer, the implementation should match the pattern shown in building-transactions.mdx lines 112-133.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The link text says "Examples" but the description says "Explore comprehensive examples in the SDK repository". However, this link points to
/build/sdks/java-sdk/java-exampleswhich is part of the documentation site, not the SDK repository. Either removetarget="_blank"since it's an internal link, or change the href to point to the actual GitHub repository examples (e.g.,https://github.com/aptos-labs/japtos/tree/main/src/test).