> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dfns.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Java SDK

> Server-side SDK for integrating DFNS into Java backends, with typed clients, request signing, and helpers for wallets, transfers, and signatures.

The Java SDK is designed for **server-side/backend** applications. It handles request signing and provides typed access to the DFNS API.

You can find the repository [on GitHub](https://github.com/dfns/dfns-sdk-java).

**Requirements:** Java 17+.

## Installation

<Tabs>
  <Tab title="Local Maven">
    <Note>
      Maven Central publishing is being finalized. Until it lands, build the SDK from source and install it into your local Maven repository.
    </Note>

    Clone the repository and publish it to your local Maven repository (`~/.m2`). The bundled Gradle wrapper downloads its own Gradle, so no local Gradle install is needed:

    ```bash theme={null}
    git clone https://github.com/dfns/dfns-sdk-java.git
    cd dfns-sdk-java
    ./gradlew publishToMavenLocal
    ```

    This installs `co.dfns:dfns-sdk-java:1.0.0` into `~/.m2/repository`. The local repository is on Maven's search path by default, so add the dependency to your `pom.xml`:

    ```xml theme={null}
    <dependency>
      <groupId>co.dfns</groupId>
      <artifactId>dfns-sdk-java</artifactId>
      <version>1.0.0</version>
    </dependency>
    ```

    Transitive dependencies (Jackson, Bouncy Castle) are declared in the published POM and resolved automatically. Re-run `./gradlew publishToMavenLocal` after pulling a newer version of the SDK.
  </Tab>

  <Tab title="From the source code">
    If you use Gradle, you can skip the publish step and build the SDK from a cloned copy as part of your own build, using a [composite build](https://docs.gradle.org/current/userguide/composite_builds.html). This needs no local Maven repository. It also works well in CI: add the SDK as a git submodule pinned to a commit, and your build resolves it reproducibly with no registry.

    Clone the repository into your project (for example as a git submodule), then reference it from your `settings.gradle`:

    ```groovy theme={null}
    includeBuild("third-party/dfns-sdk-java")
    ```

    Depend on it without a version. Gradle builds the SDK from source and substitutes it for the dependency, resolving its transitive dependencies automatically:

    ```groovy theme={null}
    dependencies {
        implementation("co.dfns:dfns-sdk-java")
    }
    ```
  </Tab>
</Tabs>

## Quick start

### 1. Read-only operations

For read-only operations (listing wallets, fetching balances, etc.), you only need an auth token:

```java theme={null}
import co.dfns.sdk.*;

DfnsClientConfig config = DfnsClientConfig.builder()
    .authToken("your-auth-token")
    .build();

try (DfnsClient client = new DfnsClient(config)) {
    PaginatedList<co.dfns.sdk.wallets.model.Wallet> wallets =
        client.wallets.listWallets(new co.dfns.sdk.wallets.model.ListWalletsQuery());

    for (var wallet : wallets.items()) {
        System.out.printf("%s: %s %s%n", wallet.id(), wallet.network(), wallet.address());
    }
}
```

<Tip>
  For a quick test you can get your login token (short-lived) from the [DFNS Dashboard](https://app.dfns.io/) under `Settings` > `Personal Access Tokens`.
</Tip>

### 2. Signing requests

State-changing operations (creating wallets, signing transactions, etc.) require cryptographic request signing:

```java theme={null}
import co.dfns.sdk.*;
import co.dfns.sdk.auth.*;
import co.dfns.sdk.wallets.model.*;

import java.nio.file.Files;
import java.nio.file.Path;

byte[] privateKey = Files.readAllBytes(Path.of("private_key.der"));
Signer signer = KeySigner.fromEd25519PrivateKey("cr-...", privateKey);

DfnsClientConfig config = DfnsClientConfig.builder()
    .authToken("your-auth-token")
    .signer(signer)
    .build();

try (DfnsClient client = new DfnsClient(config)) {
    Wallet wallet = client.wallets.createWallet(
        new CreateWalletRequest(Network.EthereumSepolia, null, null, null, null, null, null)
    );
    System.out.printf("Created wallet: %s%n", wallet.id());
}
```

## Next steps

* **[Create a service account](/guides/developers/service-account)** for server-to-server authentication with long-lived tokens
* **[Development guide](/sdks/backend/java/development)** for detailed request signing architecture


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.