getAccountModule

abstract suspend fun getAccountModule(accountAddress: AccountAddressInput, moduleName: String, param: LedgerVersionQueryParam.() -> Unit = {}): Result<MoveModuleBytecode, AptosSdkError>

Retrieves a specific Move module from an account by its name.

An optional ledger version can be provided to view the module as it existed at a specific point in time.

Usage

val address = AccountAddress.fromString("0x...")
val moduleName = "coin"
val moduleResult = aptos.getAccountModule(address, moduleName)

when (moduleResult) {
is Result.Ok -> println("Successfully retrieved module ABI: ${moduleResult.value.abi}")
is Result.Err -> println("Error retrieving module: ${moduleResult.error.message}")
}

Return

A Result which is either Ok containing the MoveModuleBytecode, or Err containing an AptosSdkError if the module is not found or another error occurs.

Parameters

accountAddress

The address of the account that owns the module.

moduleName

The name of the module to retrieve.

param

A lambda to configure optional query parameters, such as ledgerVersion.