# API Reference

#### `buildETHTransaction`

Builds an Ethereum transaction.

* @param var1 The request object containing Ethereum transaction details.
* @return A byte array containing the raw Ethereum transaction.
* @throws Exception If the transaction building fails.

**Example**:

```kotlin
try {
    // Prepare the request object with transaction details
    val ethTransactionRequest = BuildETHTransactionRequest()

    // Call the buildETHTransaction method
    val rawTransaction = client.buildETHTransaction(ethTransactionRequest)

    // Print the raw transaction details
    println("Ethereum Transaction Built Successfully!")
    println("Raw Transaction: ${rawTransaction.contentToString()}")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error building Ethereum transaction: ${e.message}")
}
```

#### buildSolTransaction

Builds a Solana transaction.

* @param var1 The request object containing Solana transaction details.
* @return A byte array containing the raw Solana transaction.
* @throws Exception If the transaction building fails.

**Example**:

```kotlin
try {
    // Prepare the request object with transaction details
    val solTransactionRequest = BuildSolTransactionRequest()

    // Call the buildSolTransaction method
    val rawTransaction = client.buildSolTransaction(solTransactionRequest)

    // Print the raw transaction details
    println("Solana Transaction Built Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error building Solana transaction: ${e.message}")
}
```

#### buildTronTransaction

Builds a Tron transaction.

* @param var1 The request object containing Tron transaction details.
* @return A byte array containing the raw Tron transaction.
* @throws Exception If the transaction building fails.

**Example**:

```kotlin
try {
    // Prepare the request object with transaction details
    val tronTransactionRequest = BuildTronTransactionRequest()

    // Call the buildTronTransaction method
    val rawTransaction = client.buildTronTransaction(tronTransactionRequest)

    // Print the raw transaction details
    println("Tron Transaction Built Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error building Tron transaction: ${e.message}")
}
```

#### `buildBTCTransaction`

Builds an BTC transaction.

* @param var1 The request object containing BTC transaction details.
* @return A byte array containing the raw BTC transaction.
* @throws Exception If the transaction building fails.

**Example**:

```kotlin
try {
    // Prepare the request object with transaction details
    val btcTransactionRequest = BuildBTCTransactionRequest()

    // Call the buildBTCTransaction method
    val rawTransaction = client.buildBTCTransaction(btcTransactionRequest)

    // Print the raw transaction details
    println("BTC Transaction Built Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error building BTC transaction: ${e.message}")
}
```

#### `buildXrpTransaction`

Builds a Xrp transaction.

* @param var1 The request object containing Xrp transaction details.
* @return A byte array containing the raw Xrp transaction.
* @throws Exception If the transaction building fails.

```kotlin
try {
    // Prepare the request object with transaction details
    val xrpTransactionRequest = BuildXrpTransactionRequest()

    // Call the buildXrpTransaction method
    val rawTransaction = client.buildXrpTransaction(xrpTransactionRequest)

    // Print the raw transaction details
    println("Xrp Transaction Built Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error building Xrp transaction: ${e.message}")
}
```

#### createKeyGenMPCGroup

Creates an MPC group for key generation.

* @param var1 The request object containing MPC group configuration.
* @return An MPCGroup object containing details of the created group.
* @throws Exception If the MPC group creation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with MPC group configuration
    val keyGenRequest = CreateKeyGenMPCGroupRequest()

    // Call the createKeyGenMPCGroup method
    val mpcGroup = client.createKeyGenMPCGroup(keyGenRequest)

    // Print details of the created MPC group
    println("MPC Group Created Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error creating MPC group: ${e.message}")
}
```

#### createPaillierMPCGroup

Creates a Paillier encryption-based MPC group.

* @param var1 The request object containing Paillier MPC group configuration.
* @return An MPCGroup object containing details of the created group.
* @throws Exception If the MPC group creation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with Paillier MPC group configuration
    val paillierRequest = CreatePaillierMPCGroupRequest()

    // Call the createPaillierMPCGroup method
    val paillierGroup = client.createPaillierMPCGroup(paillierRequest)

    // Print details of the created Paillier MPC group
    println("Paillier MPC Group Created Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error creating Paillier MPC group: ${e.message}")
}
```

#### getUserSetting

Retrieves user-specific settings.

* @return A byte array containing the serialized user settings.
* @throws Exception If the settings retrieval fails.

**Example**:

```kotlin
try {
    // Call the getUserSetting method
    val userSettings = client.getUserSetting()

    // Convert the byte array to a readable format (e.g., JSON String) if necessary
    val settingsJson = String(userSettings)
    println("User Settings Retrieved Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error retrieving user settings: ${e.message}")
}
```

#### listBlockChainTransaction

Lists blockchain transactions based on the provided filtering criteria.

* @param var1 The request object containing parameters for filtering blockchain transactions.
* @return A `ListBlockchainTransactionsResponse` object containing the list of transactions.
* @throws Exception If the operation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with transaction filtering criteria
    val transactionRequest = ListBlockchainTransactionsRequest()

    // Call the listBlockChainTransaction method
    val response = client.listBlockChainTransaction(transactionRequest)

    // Process and print the list of transactions
    println("Blockchain Transactions Retrieved Successfully!")}

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error retrieving blockchain transactions: ${e.message}")
}
```

#### listMPCGroups

Lists existing MPC groups with pagination support.

* @param var1 The request object containing pagination details.
* @return A `ListMPCGroupsResponse` object containing the list of MPC groups.
* @throws Exception If the operation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with pagination details
    val paginationRequest = PaginationRequest(
        page = 1,         // The page number to retrieve
        pageSize = 10     // The number of items per page
    )

    // Call the listMPCGroups method
    val response = client.listMPCGroups(paginationRequest)

    // Process and print the list of MPC groups
    println("MPC Groups Retrieved Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error retrieving MPC groups: ${e.message}")
}
```

#### prepareAASmartAccount

Prepares an Account Abstraction (AA) smart account.

* @param var1 The request object containing smart account setup details.
* @return An `AASmartAccount` object containing the prepared account details.
* @throws Exception If the preparation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with the details for the smart account
    val aaSmartAccountRequest = PrepareAASmartAccountRequest( )

    // Call the prepareAASmartAccount method
    val smartAccount = client.prepareAASmartAccount(aaSmartAccountRequest)

    // Print the details of the prepared smart account
    println("Smart Account Prepared Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error preparing smart account: ${e.message}")
}
```

#### prepareAATxUserOp

Prepares a user operation for Account Abstraction (AA) transactions.

* @param var1 The request object containing the details of the user operation to prepare.
* @return A `PrepareAATxUserOpResponse` object containing the prepared user operation.
* @throws Exception If the preparation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with user operation details
    val userOpRequest = PrepareAATxUserOpRequest()

    // Call the prepareAATxUserOp method
    val userOpResponse = client.prepareAATxUserOp(userOpRequest)

    // Print the details of the prepared user operation
    println("User Operation Prepared Successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error preparing user operation: ${e.message}")
}
```

#### profile

Retrieves the user's profile.

* @return A `User` object containing the user's profile details.
* @throws Exception If the profile retrieval fails.

**Example**:

```kotlin
try {
    // Call the profile method
    val userProfile = client.profile()

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error retrieving user profile: ${e.message}")
}
```

#### saveUserSetting

Saves user-specific settings.

* @param var1 The request object containing user settings to save.
* @throws Exception If the operation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with the user setting details
    val saveUserSettingRequest = SaveUserSettingRequest()

    // Call the saveUserSetting method
    client.saveUserSetting(saveUserSettingRequest)

    // Confirm the operation's success
    println("User setting saved successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error saving user setting: ${e.message}")
}
```

#### sendUserOperation

Sends a user operation to the blockchain for Account Abstraction (AA) transactions.

* @param var1 The request object containing operation details.
* @return A `String` containing the transaction hash of the executed operation.
* @throws Exception If the operation submission fails.

**Example**:

```kotlin
try {
    // Prepare the request object with operation details
    val sendUserOperationRequest = SendUserOperationRequest()

    // Call the sendUserOperation method
    val transactionHash = client.sendUserOperation(sendUserOperationRequest)

    // Print the transaction hash
    println("User operation sent successfully!")
    println("Transaction Hash: $transactionHash")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error sending user operation: ${e.message}")
}
```

#### signing

Executes signing operations for an MPC group.

* @param var1 The request object containing signing operation details.
* @return A `ByteArray` containing the digital signature.
* @throws Exception If the signing operation fails.

**Example**:

```kotlin
try {
    // Prepare the request object with signing operation details
    val signingRequest = SigningRequest()

    // Call the signing method
    val signature = client.signing(signingRequest)

    // Print the digital signature
    println("Signing operation completed successfully!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error performing signing operation: ${e.message}")
}
```

#### mpcKeyGen

Performs key generation that is compatible with Mnemonic Phrase.

* @param var1 The request object containing key generation details.
* @return A `MPCKeyGenRequest` object containing the details of the generated keys and associated metadata.
* @throws Exception If the key generation fails.

**Example**:

```kotlin

try {
    // Prepare the request object with key generation details
    val keyGenRequest = MPCKeyGenRequest(
        groupID = "Your Group ID", 
        wallets: List<MpcKeyGenWallet>,
        name: String
    )

    // Call the mpcKeyGen method
    val walletesponse = client.mpcKeyGen(MPCKeyGenRequest)

    // Print the details of the key generation response
    println("Key Generation Successful!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error during Key Generation: ${e.message}")
}
```

#### mnemonicKeyGen

Performs key generation that is compatible with Mnemonic Phrase.

* @param var1 The request object containing key generation details.
* @return A `MnemonicKeyGenRequest` object containing the details of the generated keys and associated metadata.
* @throws Exception If the key generation fails.

**Example**:

```kotlin

try {
    // Prepare the request object with key generation details
    val keyGenRequest = MnemonicKeyGenRequest(
        mnemonic = "Your Mnemonic", 
    )

    // Call the mnemonicKeyGen method
    val walletesponse = client.mnemonicKeyGen(MnemonicKeyGenRequest)

    // Print the details of the key generation response
    println("Key Generation Successful!")

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error during Key Generation: ${e.message}")
}
```

#### validateETHAddr

Validates the given Ethereum address.

* @param var1 The request object containing the Ethereum address to validate.
* @return `true` if the Ethereum address is valid, `false` otherwise.

**Example**:

```kotlin
try {
    // Prepare the request object with the Ethereum address to validate
    val validateETHAddressRequest = ValidateETHAddressRequest()

    // Call the validateETHAddr method
    val isValid = client.validateETHAddr(validateETHAddressRequest)

    // Print the validation result
    if (isValid) {
        println("The Ethereum address is valid.")
    } else {
        println("The Ethereum address is invalid.")
    }

} catch (e: Exception) {
    // Handle any exceptions that occur during the operation
    println("Error validating Ethereum address: ${e.message}")
}
```

#### exportMnemonic

Exports the mnemonic phrase for a given key generation group.

* @param keygenGroupId The unique identifier of the key generation group.
* @param keyIdentities The key identities associated with the group.
* @return A String containing the exported mnemonic phrase.

**Example**:

```kotlin
fun main() {
    try {
        // Define key generation group ID and key identities
        val keygenGroupId = "group12345"
        val keyIdentities = "identity12345"

        // Call exportMnemonic to export the mnemonic
        val mnemonic = exportMnemonic(keygenGroupId, keyIdentities)

        // Print the exported mnemonic
        println("Exported Mnemonic: $mnemonic")
    } catch (e: Exception) {
        // Handle exceptions
        println("Error exporting mnemonic: ${e.message}")
    }
}
```

#### deleteMPCGroup

Deletes a Paillier MPC group.

* @param groupID The unique identifier of the group to delete.

**Example**:

```kotlin
fun main() {
    try {
        // Initialize the group ID
        val groupID = "keyGenGroupID"

        // Call deleteGroup to delete the group
        deleteGroup(groupID)

        // Print success message
        println("Group with ID $groupID deleted successfully!")
    } catch (e: Exception) {
        // Handle exceptions
        println("Failed to delete group: ${e.message}")
    }
}
```

#### getCurrentPolicy

Retrieves the current transaction policy.

* @return A Flow emitting the current transaction policy.

**Example**:

```kotlin
fun main() {
    try {
        // Retrieve the current transaction policy
        getCurrentPolicy()
        .collect { policy ->
            // Print details of the retrieved policy
            println("Current Transaction Policy: $policy")
        }
    } catch (e: Exception) {
        // Handle any exceptions
        println("Error retrieving transaction policy: ${e.message}")
    }
}
```

#### enablePolicy

Enables the current policy with the specified delay in hours and a force flag.

* @param delayHours The delay (in hours) before enabling the policy.
* @param force A flag indicating whether to override any existing or in-progress policies.
* @throws IllegalStateException If \[whiteListRepository] is not initialized.
* @return A \[Flow] emitting the updated \[Policy].

**Example**:

```kotlin
  fun main() = runBlocking {
      // Assume we have an instance of a class that implements enablePolicy()
      val updatedPolicyFlow = yourClassInstance.enablePolicy(
          delayHours = 24,
          force = true
      )
 
      updatedPolicyFlow.collect { policy ->
          println("Policy enabled: $policy")
      }
  }
```

#### disablePolicy

Disables the current policy and emits the updated \[Policy].

**Example**:

```kotlin
  fun main() = runBlocking {
      // Assume we have an instance of a class that implements disablePolicy()
      val updatedPolicyFlow = yourClassInstance.disablePolicy()
 
      updatedPolicyFlow.collect { policy ->
          println("Policy disabled: $policy")
      }
  }
```

#### addWalletAddress

Adds a wallet address for a specific network chain with the provided labels.

* @param address The wallet address to be added.
* @param networkChain The blockchain network chain the address belongs to.
* @param labels A list of labels associated with this address.
* @throws IllegalStateException If \[whiteListRepository] is not initialized.
* @return A \[Flow] emitting the newly added \[Address].

**Example**:

```kotlin
  fun main() = runBlocking {
      // Assume we have an instance of a class that implements addWalletAddress()
      val newAddressFlow = yourClassInstance.addWalletAddress(
          address = "0x123abc...",
          networkChain = "ETH",
          labels = listOf("whitelist", "test-address")
      )
 
      newAddressFlow.collect { address ->
          println("Address added: $address")
      }
  }
```

#### removeWalletAddress

Removes the specified wallet address by its unique identifier.

* @param walletId The unique identifier of the wallet address to remove.
* @throws IllegalStateException If \[whiteListRepository] is not initialized.
* @return A \[Flow] of \[Unit] that completes once the wallet address is removed.

**Example**:

```kotlin
  fun main() = runBlocking {
      // Assume we have an instance of a class that implements removeWalletAddress()
      yourClassInstance.removeWalletAddress("walletId12345")
          .collect {
              println("Wallet address removed!")
          }
  }
```

#### updateWalletAddress

Updates an existing wallet address, identified by \[walletId], with a new set of \[labels].

* @param walletId The unique identifier of the wallet address to update.
* @param labels A list of new labels to be applied to this wallet address.
* @throws IllegalStateException If \[whiteListRepository] is not initialized.
* @return A \[Flow] emitting the updated \[Address].

**Example**:

```kotlin
  fun main() = runBlocking {
      // Assume we have an instance of a class that implements updateWalletAddress()
      val updatedAddressFlow = yourClassInstance.updateWalletAddress(
          walletId = "walletId12345",
          labels = listOf("verified", "my-label")
      )
 
      updatedAddressFlow.collect { updatedAddress ->
          println("Updated address: $updatedAddress")
      }
  }
```
