Skip to main content

Getting Started with Java

Password Storage

It is not recommended to store passwords or seeds on a host's environment variables or in the source code in a production setup. Please follow our backup and security recommendations for production use.

Requirements

Install the Library with Maven

linux-x86_64

<dependency>
<groupId>org.iota</groupId>
<artifactId>iota-wallet-java</artifactId>
<version>1.0.0-rc.2</version>
<type>jar</type>
<classifier>linux-x86_64</classifier>
</dependency>

windows-x86_64

<dependency>
<groupId>org.iota</groupId>
<artifactId>iota-wallet-java</artifactId>
<version>1.0.0-rc.2</version>
<type>jar</type>
<classifier>windows-x86_64</classifier>
</dependency>

aarch64-apple-darwin

<dependency>
<groupId>org.iota</groupId>
<artifactId>iota-wallet-java</artifactId>
<version>1.0.0-rc.2</version>
<type>jar</type>
<classifier>aarch64-apple-darwin</classifier>
</dependency>

osx-x86_64

<dependency>
<groupId>org.iota</groupId>
<artifactId>iota-wallet-java</artifactId>
<version>1.0.0-rc.2</version>
<type>jar</type>
<classifier>osx-x86_64</classifier>
</dependency>

Use the Library

In order to use the library, you need to create a Wallet:

// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import org.iota.Wallet;
import org.iota.types.AccountHandle;
import org.iota.types.ClientConfig;
import org.iota.types.CoinType;
import org.iota.types.WalletConfig;
import org.iota.types.exceptions.WalletException;
import org.iota.types.secret.StrongholdSecretManager;

public class CreateAccount {
private static final String DEFAULT_DEVELOPMENT_MNEMONIC = "hidden enroll proud copper decide negative orient asset speed work dolphin atom unhappy game cannon scheme glow kid ring core name still twist actor";

public static void main(String[] args) throws WalletException {
// Build the wallet.
Wallet wallet = new Wallet(new WalletConfig()
.withClientOptions(new ClientConfig().withNodes("https://api.testnet.shimmer.network"))
.withSecretManager(new StrongholdSecretManager("PASSWORD_FOR_ENCRYPTION", null, "example-wallet"))
.withCoinType(CoinType.Shimmer)
);
wallet.storeMnemonic(DEFAULT_DEVELOPMENT_MNEMONIC);

// Create an account.
AccountHandle a = wallet.createAccount("Alice");

// Print the account.
System.out.println(a);
}
}

What's Next?

Now that you are up and running, you can get acquainted with the library using its how-to guides and the repository's code examples.