Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions astro.sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ export const sidebar = [
}),
],
}),
group("build.group.sdks.java-sdk", {
collapsed: true,
items: [
"build/sdks/java-sdk",
"build/sdks/java-sdk/quickstart",
"build/sdks/java-sdk/account",
"build/sdks/java-sdk/building-transactions",
"build/sdks/java-sdk/java-examples",
],
}),
// Python SDK (no subpages found)
"build/sdks/python-sdk",
// Unity SDK (no subpages found)
Expand Down
2 changes: 2 additions & 0 deletions src/content/docs/build/sdks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Use these Aptos software development kits (SDKs), in combination with the [Aptos

<LinkCard href="/build/sdks/dotnet-sdk" title="C#/.NET SDK" description="Aptos .NET SDK" />

<LinkCard href="/build/sdks/java-sdk" title="Java SDK" description="Aptos Java SDK with multi-sig and HD wallet support" />

<LinkCard href="/build/sdks/rust-sdk" title="Rust SDK" description="Aptos Rust SDK" />

<LinkCard href="/build/sdks/cpp-sdk" title="C++ / Unreal SDK" description="Aptos C++ / Unreal SDK" />
Expand Down
179 changes: 179 additions & 0 deletions src/content/docs/build/sdks/java-sdk.mdx
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">
![Github Repo Stars](https://img.shields.io/github/stars/aptos-labs/japtos)
</a>

<a target="_blank" href="https://github.com/aptos-labs/japtos">
![Static Badge](https://img.shields.io/badge/SDK_Reference-Docs)
</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" />
Copy link

Copilot AI Nov 24, 2025

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-examples which is part of the documentation site, not the SDK repository. Either remove target="_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).

Suggested change
<LinkCard href="/build/sdks/java-sdk/java-examples" title="Examples" description="Explore comprehensive examples in the SDK repository" target="_blank" />
<LinkCard href="https://github.com/aptos-labs/japtos/tree/main/src/test" title="Examples" description="Explore comprehensive examples in the SDK repository" target="_blank" />

Copilot uses AI. Check for mistakes.
</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.).
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect information about faucet availability. The statement says "For Mainnet and Testnet, you'll need to fund accounts through other means (exchanges, faucets, etc.)" which is confusing because it says Testnet doesn't have faucet access but then mentions "faucets" as an alternative means. According to /network/faucet.mdx, Testnet does have a faucet available. The comment should clarify: "Account funding via the SDK's fundAccount() method is only available on Devnet and Localnet. For Testnet, use the Testnet Faucet. For Mainnet, you'll need to acquire APT through exchanges or other means."

Suggested change
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 uses AI. Check for mistakes.
:::

## Transfer APT Example

Here's a quick example of how to transfer APT tokens:

```java
import com.aptoslabs.japtos.account.Ed25519Account;
import com.aptoslabs.japtos.client.AptosClient;
import com.aptoslabs.japtos.api.AptosConfig;
import com.aptoslabs.japtos.transaction.*;
import com.aptoslabs.japtos.types.*;

// Setup client
AptosConfig config = AptosConfig.builder()
.network(AptosConfig.Network.DEVNET)
.build();
AptosClient client = new AptosClient(config);

// Create accounts
Ed25519Account alice = Ed25519Account.generate();
Ed25519Account bob = Ed25519Account.generate();

// Fund accounts (devnet only)
client.fundAccount(alice.getAccountAddress(), 100_000_000);
client.fundAccount(bob.getAccountAddress(), 100_000_000);

// Build transfer transaction
ModuleId moduleId = new ModuleId(
AccountAddress.fromHex("0x1"),
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()
))),
Comment on lines +128 to +139
Copy link

Copilot AI Nov 24, 2025

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.

Suggested change
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 uses AI. Check for mistakes.
Arrays.asList(
new TransactionArgument.AccountAddress(bob.getAccountAddress()),
new TransactionArgument.U64(1_000_000L) // 0.01 APT
)
);
Comment on lines +126 to +144
Copy link

Copilot AI Nov 24, 2025

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.

Copilot uses AI. Check for mistakes.

// Get account sequence number and chain ID
long sequenceNumber = client.getAccountSequenceNumber(alice.getAccountAddress());
int chainId = client.getChainId();

// Build and sign transaction
RawTransaction rawTx = new RawTransaction(
alice.getAccountAddress(),
sequenceNumber,
payload,
1000000L, // maxGasAmount
100L, // gasUnitPrice
System.currentTimeMillis() / 1000 + 3600, // expiration
chainId
);

SignedTransaction signedTx = new SignedTransaction(
rawTx,
alice.signTransactionWithAuthenticator(rawTx)
);

// Submit and wait for transaction
PendingTransaction pendingTx = client.submitTransaction(signedTx);
Transaction tx = client.waitForTransaction(pendingTx.getHash());

System.out.println("Transaction completed: " + tx.isSuccess());
```

## Resources

- [GitHub Repository](https://github.com/aptos-labs/japtos)
- [Quickstart Guide](/build/sdks/java-sdk/quickstart)
- [Account Management](/build/sdks/java-sdk/account)
- [Building Transactions](/build/sdks/java-sdk/building-transactions)

Loading
Loading