Class: Iota
Class for performing operations on IOTA.
Constructors
Constructor
new Iota():
Iota
Returns
Iota
Properties
DEFAULT_MNEMONIC_SECRET_NAME
readonlystaticDEFAULT_MNEMONIC_SECRET_NAME:string="mnemonic"
Default name for the mnemonic secret.
DEFAULT_SEED_SECRET_NAME
readonlystaticDEFAULT_SEED_SECRET_NAME:string="seed"
Default name for the seed secret.
DEFAULT_COIN_TYPE
readonlystaticDEFAULT_COIN_TYPE:number=4218
Default coin type.
DEFAULT_SCAN_RANGE
readonlystaticDEFAULT_SCAN_RANGE:number=1000
Default scan range.
DEFAULT_INCLUSION_TIMEOUT
readonlystaticDEFAULT_INCLUSION_TIMEOUT:number=60
Default inclusion timeout.
CLASS_NAME
readonlystaticCLASS_NAME:string
Runtime name for the class.
Methods
createClient()
staticcreateClient(config):IotaClient
Create a new IOTA client.
Parameters
config
The configuration.
Returns
IotaClient
The client instance.
populateConfig()
staticpopulateConfig(config):void
Create configuration using defaults where necessary.
Parameters
config
The configuration to populate.
Returns
void
getAddresses()
staticgetAddresses(seed,coinType,accountIndex,startAddressIndex,count,isInternal?):string[]
Get addresses for the identity.
Parameters
seed
Uint8Array
The seed to use for generating addresses.
coinType
number
The coin type to use.
accountIndex
number
The account index to get the addresses for.
startAddressIndex
number
The start index for the addresses.
count
number
The number of addresses to generate.
isInternal?
boolean
Whether the addresses are internal.
Returns
string[]
The list of addresses.
getKeyPair()
staticgetKeyPair(seed,coinType,accountIndex,addressIndex,isInternal?):object
Get a key pair for the specified index.
Parameters
seed
Uint8Array
The seed to use for generating the key pair.
coinType
number
The coin type to use.
accountIndex
number
The account index to get the key pair for.
addressIndex
number
The address index to get the key pair for.
isInternal?
boolean
Whether the address is internal.
Returns
object
The key pair containing private key and public key.
privateKey
privateKey:
Uint8Array
publicKey
publicKey:
Uint8Array
createTransaction()
staticcreateTransaction():Transaction
Create a new transaction instance.
Returns
Transaction
A new transaction instance.
prepareAndPostValueTransaction()
staticprepareAndPostValueTransaction(config,vaultConnector,logging,identity,client,source,amount,recipient,options?):Promise<IotaTransactionBlockResponse>
Prepare and post a transaction.
Parameters
config
The configuration.
vaultConnector
IVaultConnector
The vault connector.
logging
ILoggingComponent | undefined
The logging component.
identity
string
The identity of the user to access the vault keys.
client
IotaClient
The client instance.
source
string
The source address.
amount
bigint
The amount to transfer.
recipient
string
The recipient address.
options?
The transaction options.
Returns
Promise<IotaTransactionBlockResponse>
The transaction result.
prepareAndPostTransaction()
staticprepareAndPostTransaction(config,vaultConnector,logging,identity,client,owner,transaction,options?):Promise<IotaTransactionBlockResponse>
Prepare and post a transaction.
Parameters
config
The configuration.
vaultConnector
IVaultConnector
The vault connector.
logging
ILoggingComponent | undefined
The logging component.
identity
string
The identity of the user to access the vault keys.
client
IotaClient
The client instance.
owner
string
The owner of the address.
transaction
Transaction
The transaction to execute.
options?
The transaction options.
Returns
Promise<IotaTransactionBlockResponse>
The transaction response.
getSeed()
staticgetSeed(config,vaultConnector,identity):Promise<Uint8Array<ArrayBufferLike>>
Get the seed from the vault.
Parameters
config
The configuration to use.
vaultConnector
IVaultConnector
The vault connector to use.
identity
string
The identity of the user to access the vault keys.
Returns
Promise<Uint8Array<ArrayBufferLike>>
The seed.
findAddress()
staticfindAddress(maxScanRange,coinType,seed,address):object
Find the address in the seed.
Parameters
maxScanRange
number
The maximum range to scan.
coinType
number
The coin type to use.
seed
Uint8Array
The seed to use.
address
string
The address to find.
Returns
object
The address key pair.
address
address:
string
privateKey
privateKey:
Uint8Array
publicKey
publicKey:
Uint8Array
Throws
Error if the address is not found.
extractPayloadError()
staticextractPayloadError(error):IError
Extract error from SDK payload. Errors from the IOTA SDK are usually not JSON strings but objects.
Parameters
error
unknown
The error to extract.
Returns
IError
The extracted error.
buildMnemonicKey()
staticbuildMnemonicKey(identity,vaultMnemonicId?):string
Get the key for storing the mnemonic.
Parameters
identity
string
The identity to use.
vaultMnemonicId?
string
The mnemonic ID to use.
Returns
string
The mnemonic key.
buildSeedKey()
staticbuildSeedKey(identity,vaultSeedId?):string
Get the key for storing the seed.
Parameters
identity
string
The identity to use.
vaultSeedId?
string
The seed ID to use.
Returns
string
The seed key.
packageExistsOnNetwork()
staticpackageExistsOnNetwork(client,packageId):Promise<boolean>
Check if the package exists on the network.
Parameters
client
IotaClient
The client to use.
packageId
string
The package ID to check.
Returns
Promise<boolean>
True if the package exists, false otherwise.
dryRunTransaction()
staticdryRunTransaction(client,logging,txb,sender,operation):Promise<IIotaDryRun>
Dry run a transaction and log the results.
Parameters
client
IotaClient
The IOTA client.
logging
ILoggingComponent | undefined
The logging component.
txb
Transaction
The transaction to dry run.
sender
string
The sender address.
operation
string
The operation to log.
Returns
Promise<IIotaDryRun>
void.
waitForTransactionConfirmation()
staticwaitForTransactionConfirmation(client,digest,config,options?):Promise<IotaTransactionBlockResponse>
Wait for a transaction to be indexed and available over the API.
Parameters
client
IotaClient
The IOTA client instance.
digest
string
The digest of the transaction to wait for.
config
The IOTA configuration.
options?
Additional options for the transaction query.
showEffects?
boolean
Whether to show effects.
showEvents?
boolean
Whether to show events.
showObjectChanges?
boolean
Whether to show object changes.
Returns
Promise<IotaTransactionBlockResponse>
The confirmed transaction response.
isAbortError()
staticisAbortError(error,code):boolean
Check if the error is an abort error with a specific code.
Parameters
error
unknown
The error to check.
code
number
The error code to check for.
Returns
boolean
True if the error is an abort error, false otherwise.
prepareAndPostGasStationTransaction()
staticprepareAndPostGasStationTransaction(config,vaultConnector,identity,client,owner,transaction,options?):Promise<IotaTransactionBlockResponse>
Prepare and post a transaction using gas station sponsoring.
Parameters
config
The configuration.
vaultConnector
IVaultConnector
The vault connector.
identity
string
The identity of the user to access the vault keys.
client
IotaClient
The client instance.
owner
string
The owner of the address.
transaction
Transaction
The transaction to execute.
options?
Response options including confirmation behavior.
Returns
Promise<IotaTransactionBlockResponse>
The transaction response.
reserveGas()
staticreserveGas(config,gasBudget):Promise<IGasReservationResult>
Reserve gas from the gas station.
Parameters
config
The configuration containing gas station settings.
gasBudget
number
The gas budget to reserve.
Returns
Promise<IGasReservationResult>
The gas reservation result.
executeGasStationTransaction()
staticexecuteGasStationTransaction(config,reservationId,transactionBytes,userSignature):Promise<IotaTransactionBlockResponse>
Execute a sponsored transaction through the gas station.
Parameters
config
The configuration containing gas station settings.
reservationId
number
The reservation ID from gas reservation.
transactionBytes
Uint8Array
The unsigned transaction bytes.
userSignature
string
The user's signature.
Returns
Promise<IotaTransactionBlockResponse>
The transaction response.
executeAndConfirmGasStationTransaction()
staticexecuteAndConfirmGasStationTransaction(config,client,reservationId,transactionBytes,userSignature,options?):Promise<IotaTransactionBlockResponse>
Execute and confirm a gas station transaction.
Parameters
config
The configuration containing gas station settings.
client
IotaClient
The IOTA client for confirmation.
reservationId
number
The reservation ID from gas reservation.
transactionBytes
Uint8Array
The unsigned transaction bytes.
userSignature
string
The user's signature.
options?
Response options including confirmation behavior.
Returns
Promise<IotaTransactionBlockResponse>
The transaction response (confirmed if waitForConfirmation is true).