fund Account
abstract suspend fun fundAccount(accountAddress: AccountAddressInput, amount: Long, options: WaitForTransactionOptions = WaitForTransactionOptions()): Result<TransactionResponse, AptosSdkError>
Requests test coins from the network's Faucet for a given account.
If the account does not exist, this function will create it and then fund it with the specified amount of coins.
Usage
val address = AccountAddress.fromString("0x...")
// Request 1 APT (100,000,000 Octas)
val resolution = aptos.fundAccount(address, 100_000_000)
when (resolution) {
is Result.Ok -> {
val transaction = resolution.value
println("Successfully funded account. Transaction: $transaction")
}
is Result.Err -> {
println("Error funding account: ${resolution.error.message}")
}
}Content copied to clipboard
Return
A Result which is either Result.Ok containing the final TransactionResponse, or Result.Err containing an AptosSdkError.
Parameters
account Address
The address of the account to fund.
amount
The amount of coins (in Octas) to fund the account with.
options
Optional configuration for waiting for the funding transaction to be processed.