Java Developers:
If you're building with Java, please review the integration notes provided in the Calling Kotlin suspending functions from Java section before proceeding.
Welcome to Circle's Modular Wallets Android SDK documentation. The SDK enables developers to integrate Circle's Modular Wallets to build secure, scalable Web3 applications by leveraging tools for key management, smart account interactions, gasless transactions, and blockchain communication.
Follow the steps provided in the GitHub repository to install and set up the Modular Wallets Android SDK.
Java Developers:
If you're building with Java, please review the integration notes provided in the Calling Kotlin suspending functions from Java section before proceeding.
The following sections detail the SDK's transport mechanisms, client interactions, account management, utility functions, and supported blockchain networks.
passkey-{timestamp}
, for example,
2025-01-01T00:00:00.000Z
) - The wallet name assigned to the newly
registered account.Blockchain Network | Token Name (Symbol) | Token Enum | Contract Address |
---|---|---|---|
Arbitrum Mainnet | USD Coin (USDC) | Arbitrum_USDC | 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 |
Arbitrum Mainnet | Arbitrum (ARB) | Arbitrum_ARB | 0x912CE59144191C1204E64559FE8253a0e49E6548 |
Base Mainnet | USD Coin (USDC) | Base_USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
Optimism Mainnet | USD Coin (USDC) | Optimism_USDC | 0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85 |
Optimism Mainnet | Optimism (OP) | Optimism_OP | 0x4200000000000000000000000000000000000042 |
Polygon Mainnet | USD Coin (USDC) | Polygon_USDC | 0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359 |
Unichain Mainnet | USD Coin (USDC) | Unichain_USDC | 0x078D782b760474a361dDA0AF3839290b0EF57AD6 |
Arbitrum Sepolia Testnet | USD Coin (USDC) | ArbitrumSepolia_USDC | 0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d |
Base Sepolia Testnet | USD Coin (USDC) | BaseSepolia_USDC | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
Optimism Sepolia Testnet | USD Coin (USDC) | OptimismSepolia_USDC | 0x5fd84259d66Cd46123540766Be93DFE6D43130D7 |
Polygon Amoy Testnet | USD Coin (USDC) | PolygonAmoy_USDC | 0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582 |
Unichain Sepolia Testnet | USD Coin (USDC) | UnichainSepolia_USDC | 0x31d0220469e10c4E71834a79b1f276d740d3768F |
{chain}_{symbol}
.The Modular Wallets Android SDK uses suspending functions for asynchronous operations. However, calling Kotlin's suspend functions from Java requires a different approach due to Java's lack of built-in coroutine support. This section explains how to invoke suspend functions from Java and demonstrates the use of a custom continuation for managing coroutine execution.
When calling a suspend function from Java, you must handle the coroutine's Continuation parameter manually. A custom Continuation class can implement Kotlin's Continuation interface to manage coroutine resumption, handling both successful results and exceptions.
Below is the suggested approach for creating and using a custom continuation in Java:
public class CustomContinuation<T> implements Continuation<T> {
private final CompletableFuture<T> future;
public CustomContinuation(CompletableFuture<T> future) {
this.future = future;
}
@Override
public void resumeWith(@NotNull Object o) {
if (o instanceof Result.Failure)
future.completeExceptionally((((Result.Failure) o).exception));
else
future.complete((T) o);
}
@NotNull
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
}
Below is an example of how to use CustomContinuation
to call the
getChainId()
suspend function, which returns a Long
value representing the
blockchain's chain ID.
try {
// Create a CompletableFuture to hold the result of the asynchronous operation
CompletableFuture<Long> suspendResult = new CompletableFuture<>();
// Call getChainId, passing in a CustomContinuation that will handle the result
bundlerClient.getChainId(new CustomContinuation<>(suspendResult));
// Wait for the CompletableFuture to complete and retrieve the result
Long chainId = suspendResult.join();
} catch(Exception e) {
e.printStackTrace;
}
This approach can be used in your Java code for invoking Kotlin suspending functions.