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
46 changes: 32 additions & 14 deletions embedded-wallets/sdk/android/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Then, in your app-level `build.gradle` dependencies section, add the following:
dependencies {
// ...
// focus-next-line
implementation 'com.github.web3auth:web3auth-android-sdk:9.1.2'
implementation 'com.github.web3auth:web3auth-android-sdk:10.0.0'
}
```

Expand Down Expand Up @@ -148,14 +148,15 @@ Create a Web3Auth instance and configure it with your project settings:
```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

// focus-start
var web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
network = Network.MAINNET,
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
)
)
// focus-end
Expand All @@ -181,7 +182,7 @@ override fun onNewIntent(intent: Intent?) {

After instantiating Web3Auth, the next step is to initialize it using the `initialize` method. This method is essential for setting up the SDK, checking for any active sessions, and fetching the whitelabel configuration from your dashboard.

Once the `initialize` method executes successfully, you can use the `getPrivKey` or `getEd25519PrivKey` methods to verify if an active session exists. If there is no active session, these methods will return an empty string; otherwise, they will return the respective private key.
Once the `initialize` method executes successfully, you can use the `getPrivateKey` or `getEd25519PrivateKey` methods to verify if an active session exists. If there is no active session, these methods will return an empty string; otherwise, they will return the respective private key.
Copy link
Member

Choose a reason for hiding this comment

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

This is changed, the initialize method will throw an error that needs to be swallowed if the session is not present.

initialize method can fail if the session is not present, or if there is an network issue to get the dashboard configuration, or session validation.

Copy link
Member Author

Choose a reason for hiding this comment

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

added extra context


:::note

Expand All @@ -194,7 +195,7 @@ val initializeCF: CompletableFuture<Void> = web3Auth.initialize()
initializeCF.whenComplete { _, error ->
if (error == null) {
// Check for the active session
if(web3Auth.getPrivKey()isNotEmpty()) {
if(web3Auth.getPrivateKey().isNotEmpty()) {
// Active session found
}
// No active session is not present
Expand Down Expand Up @@ -235,7 +236,7 @@ val web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_CLIENT_ID",
network = Network.SAPPHIRE_MAINNET, // or Network.SAPPHIRE_DEVNET
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
redirectUrl = "YOUR_APP_SCHEME://auth"
)
)
Expand All @@ -250,11 +251,11 @@ val web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_CLIENT_ID",
network = Network.SAPPHIRE_MAINNET, // or Network.SAPPHIRE_DEVNET
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET, // or Web3AuthNetwork.SAPPHIRE_DEVNET
redirectUrl = "YOUR_APP_SCHEME://auth"
loginConfig = hashMapOf("google" to LoginConfigItem(
verifier = "verifier-name", // Get it from Web3Auth dashboard
typeOfLogin = TypeOfLogin.GOOGLE,
authConnectionConfig = listOf(AuthConnectionConfig(
authConnectionId = "auth-connection-id", // Get it from Web3Auth dashboard
authConnection = AuthConnection.GOOGLE,
clientId = getString(R.string.google_client_id) // Google's client id
)),
mfaSettings = MfaSettings(
Expand All @@ -273,13 +274,30 @@ val web3Auth = Web3Auth(

</Tabs>

## Single Factor Auth (SFA) Support

Web3Auth Android SDK includes built-in support for Single Factor Auth (SFA), allowing for seamless authentication when you already have a JWT token from your authentication system. When MFA is disabled, users won't even notice Web3Auth's presence - they'll be automatically authenticated using just your JWT token, making the login experience completely frictionless.

```kotlin
// SFA login with custom JWT
val loginCompletableFuture = web3Auth.connectTo(
LoginParams(
AuthConnection.CUSTOM,
authConnectionId = "your_verifier_id",
idToken = "your_jwt_token"
)
)
```

SFA mode is automatically activated when you provide an `idToken` parameter. This enables direct authentication without additional social login steps, perfect for applications that already have their own authentication system.

## Blockchain Integration

Web3Auth is blockchain agnostic, enabling integration with any blockchain network. Out of the box, Web3Auth offers robust support for both **Solana** and **Ethereum**.

### Ethereum Integration

For Ethereum integration, you can get the private key using the `getPrivKey` method and use it with web3j or other Ethereum libraries:
For Ethereum integration, you can get the private key using the `getPrivateKey` method and use it with web3j or other Ethereum libraries:

```kotlin
import org.web3j.crypto.Credentials
Expand All @@ -288,7 +306,7 @@ import org.web3j.protocol.Web3j
import org.web3j.protocol.http.HttpService

// Use your Web3Auth instance to get the private key
val privateKey = web3Auth.getPrivKey()
val privateKey = web3Auth.getPrivateKey()

// Generate the Credentials
val credentials = Credentials.create(privateKey)
Expand All @@ -308,7 +326,7 @@ val ethBalance = BigDecimal.valueOf(balanceResponse.balance.toDouble()).divide(B

### Solana Integration

For Solana integration, you can get the Ed25519 private key using the `getEd25519PrivKey` method and use it with sol4k or any other Solana libraries:
For Solana integration, you can get the Ed25519 private key using the `getEd25519PrivateKey` method and use it with sol4k or any other Solana libraries:

```kotlin
import org.sol4k.Connection
Expand All @@ -317,7 +335,7 @@ import org.sol4k.Keypair
val connection = Connection(RpcUrl.DEVNET)

// Use your Web3Auth instance to get the private key
val ed25519PrivateKey = web3Auth.getEd25519PrivKey()
val ed25519PrivateKey = web3Auth.getEd25519PrivateKey()

// Generate the Solana KeyPair
val solanaKeyPair = Keypair.fromSecretKey(ed25519PrivateKey.hexToByteArray())
Expand Down
49 changes: 28 additions & 21 deletions embedded-wallets/sdk/android/advanced/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ When setting up Web3Auth, you'll pass in the options to the constructor. This co
```kotlin
import com.web3auth.core.Web3Auth
import com.web3auth.core.types.Web3AuthOptions
import org.torusresearch.fetchnodedetails.types.Web3AuthNetwork

// focus-start
var web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
network = Network.MAINNET,
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
)
)
// focus-end
Expand All @@ -50,21 +51,24 @@ The Web3Auth Constructor takes an object with `Web3AuthOptions` as input.
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `context` | Android context to launch Web-based authentication, usually is the current activity. It's a mandatory field, and accepts `android.content.Context` as a value. |
| `clientId` | Your Web3Auth Client ID. You can get it from Web3Auth [Dashboard](https://dashboard.web3auth.io/) under project details. It's a mandatory field of type `String` |
| `network` | Defines the Web3Auth Network. It's a mandatory field of type Network. |
| `redirectUrl` | URL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type `Uri`. |
| `web3AuthNetwork` | Defines the Web3Auth Network. It's a mandatory field of type `Web3AuthNetwork`. |
| `redirectUrl` | URL that Web3Auth will redirect API responses upon successful authentication from browser. It's a mandatory field of type `String`. |
Comment on lines +54 to +55
Copy link
Member

@AyushBherwani1998 AyushBherwani1998 Sep 22, 2025

Choose a reason for hiding this comment

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

There are lot of new parameters added. Top of my head, missing default chain id, account abstraction config.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

| `sessionTime?` | It allows developers to configure the session management time. Session Time is in seconds, default is 86400 seconds which is 1 day. `sessionTime` can be max 30 days |
| `useCoreKitKey?` | Use CoreKit (or SFA) Key to get core kit key given by SFA SDKs. It's an optional field with default value as `false`. Useful for Wallet Pregeneration. |
| `chainNamespace?` | Chain Namespace [`EIP155` and `SOLANA`]. It takes `ChainNamespace` as a value. |
| `useSFAKey?` | Use SFA Key to get single factor auth key. It's an optional field with default value as `false`. Useful for Wallet Pregeneration and SFA mode. |
| `chains?` | Custom chain configuration for blockchain networks. It takes `Chains` as a value. |
| `defaultChainId?` | Default chain ID to use. It's an optional field with default value as `null`. The first chain in the list will be used if not provided. |
| `enableLogging?` | Setting to true will enable logs. It's an optional field with default value as `false`. |

</TabItem>

<TabItem value="advanced">

| Parameter | Description |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `whiteLabel?` | WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes `WhiteLabelData` as a value. |
| `loginConfig?` | Login config for the custom verifiers. It takes `HashMap<String, LoginConfigItem>` as a value. |
| `mfaSettings?` | Allows developers to configure the Mfa settings for authentication. It takes `MfaSettings` as a value. |
| Parameter | Description |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `whiteLabel?` | WhiteLabel options for web3auth. It helps you define custom UI, branding, and translations for your brand app. It takes `WhiteLabelData` as a value. |
| `authConnectionConfig?` | Auth connection config for the custom auth connections. It takes `List<AuthConnectionConfig>` as a value. |
| `mfaSettings?` | Allows developers to configure the MFA settings for authentication. It takes `MfaSettings` as a value. |
| `walletServicesConfig?` | Configuration for wallet services including whitelabel options. It takes `WalletServicesConfig` as a value. |

</TabItem>

Expand All @@ -74,16 +78,19 @@ The Web3Auth Constructor takes an object with `Web3AuthOptions` as input.
data class Web3AuthOptions(
var context: Context,
val clientId: String,
val network: Network,
var buildEnv: BuildEnv? = BuildEnv.PRODUCTION,
@Transient var redirectUrl: Uri,
var sdkUrl: String = getSdkUrl(buildEnv),
val web3AuthNetwork: Web3AuthNetwork,
Copy link
Member

Choose a reason for hiding this comment

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

Missing few, can't see account abstraction config.

Copy link
Member Author

Choose a reason for hiding this comment

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

added

var authBuildEnv: BuildEnv? = BuildEnv.PRODUCTION,
var redirectUrl: String,
var sdkUrl: String = getSdkUrl(authBuildEnv),
val whiteLabel: WhiteLabelData? = null,
val loginConfig: HashMap<String, LoginConfigItem>? = null,
val useCoreKitKey: Boolean? = false,
val chainNamespace: ChainNamespace? = ChainNamespace.EIP155,
val authConnectionConfig: List<AuthConnectionConfig>? = null,
val useSFAKey: Boolean? = false,
val chains: Chains? = null,
val mfaSettings: MfaSettings? = null,
val sessionTime: Int? = 86400
val sessionTime: Int = 86400,
val walletServicesConfig: WalletServicesConfig? = null,
val defaultChainId: String? = null,
val enableLogging: Boolean? = false
)
```

Expand All @@ -106,9 +113,9 @@ var web3Auth = Web3Auth(
Web3AuthOptions(
context = this,
clientId = "YOUR_WEB3AUTH_CLIENT_ID", // Pass over your Web3Auth Client ID from Developer Dashboard
network = Network.MAINNET,
web3AuthNetwork = Web3AuthNetwork.SAPPHIRE_MAINNET,
sessionTime = 86400 * 7, // 7 days (in seconds)
redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"),
redirectUrl = "{YOUR_APP_PACKAGE_NAME}://auth",
)
)
```
Expand Down
Loading
Loading