This project is currently in Beta.While we’ve worked hard to ensure its functionality, stability, and security, there may still be bugs, performance issues, or unexpected behavior.
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 here.
Requirements: Java 17+.
Quick start
1. Read-only operations
For read-only operations (listing wallets, fetching balances, etc.), you only need an auth token:
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());
}
}
For a quick test you can get your login token (short-lived) from the Dfns Dashboard under Settings > Personal Access Tokens.
2. Signing requests
State-changing operations (creating wallets, signing transactions, etc.) require cryptographic request signing:
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