Skip to main content

Class: Account

The Account class.

Table of contents

Constructors

Methods

Constructors

constructor

new Account(accountMeta, methodHandler)

Parameters

NameTypeDescription
accountMetaAccountMetaAn instance of AccountMeta.
methodHandlerWalletMethodHandlerA instance of WalletMethodHandler.

Methods

buildAliasOutput

buildAliasOutput(data): Promise<AliasOutput>

Parameters

NameType
dataBuildAliasOutputData

Returns

Promise<AliasOutput>

Deprecated

use Client::buildAliasOutput() instead.


buildBasicOutput

buildBasicOutput(data): Promise<BasicOutput>

Parameters

NameType
dataBuildBasicOutputData

Returns

Promise<BasicOutput>

Deprecated

use Client::buildBasicOutput() instead.


buildFoundryOutput

buildFoundryOutput(data): Promise<FoundryOutput>

Parameters

NameType
dataBuildFoundryOutputData

Returns

Promise<FoundryOutput>

Deprecated

use Client::buildFoundryOutput() instead.


buildNftOutput

buildNftOutput(data): Promise<NftOutput>

Parameters

NameType
dataBuildNftOutputData

Returns

Promise<NftOutput>

Deprecated

use Client::buildNftOutput() instead.


prepareBurn

prepareBurn(burn, transactionOptions?): Promise<PreparedTransaction>

A generic burn() function that can be used to prepare to burn native tokens, nfts, foundries and aliases.

Parameters

NameTypeDescription
burnBurnThe outputs to burn
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


prepareBurnNativeToken

prepareBurnNativeToken(tokenId, burnAmount, transactionOptions?): Promise<PreparedTransaction>

Burn native tokens. This doesn't require the foundry output which minted them, but will not increase the foundries melted_tokens field, which makes it impossible to destroy the foundry output. Therefore it's recommended to use melting, if the foundry output is available.

Parameters

NameTypeDescription
tokenIdstringThe native token id.
burnAmountbigintThe to be burned amount.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


prepareBurnNft

prepareBurnNft(nftId, transactionOptions?): Promise<PreparedTransaction>

Burn an nft output.

Parameters

NameTypeDescription
nftIdstringThe NftId.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


claimOutputs

claimOutputs(outputIds): Promise<Transaction>

Claim basic or nft outputs that have additional unlock conditions to their AddressUnlockCondition from the account.

Parameters

NameTypeDescription
outputIdsstring[]The outputs to claim.

Returns

Promise<Transaction>

The resulting transaction.


prepareConsolidateOutputs

prepareConsolidateOutputs(params): Promise<PreparedTransaction>

Consolidate basic outputs with only an AddressUnlockCondition from an account by sending them to an own address again if the output amount is greater or equal to the output consolidation threshold.

Parameters

NameType
paramsConsolidationParams

Returns

Promise<PreparedTransaction>

The prepared consolidation transaction.


prepareCreateAliasOutput

prepareCreateAliasOutput(params?, transactionOptions?): Promise<PreparedTransaction>

createAliasOutput creates an alias output

Parameters

NameTypeDescription
params?AliasOutputParamsThe alias output options.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


prepareMeltNativeToken

prepareMeltNativeToken(tokenId, meltAmount, transactionOptions?): Promise<PreparedTransaction>

Melt native tokens. This happens with the foundry output which minted them, by increasing its melted_tokens field.

Parameters

NameTypeDescription
tokenIdstringThe native token id.
meltAmountbigintTo be melted amount.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


deregisterParticipationEvent

deregisterParticipationEvent(eventId): Promise<void>

Deregister a participation event.

Parameters

NameTypeDescription
eventIdstringThe id of the participation event to deregister.

Returns

Promise<void>


prepareDestroyAlias

prepareDestroyAlias(aliasId, transactionOptions?): Promise<PreparedTransaction>

Destroy an alias output.

Parameters

NameTypeDescription
aliasIdstringThe AliasId.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


prepareDestroyFoundry

prepareDestroyFoundry(foundryId, transactionOptions?): Promise<PreparedTransaction>

Function to destroy a foundry output with a circulating supply of 0. Native tokens in the foundry (minted by other foundries) will be transacted to the controlling alias.

Parameters

NameTypeDescription
foundryIdstringThe FoundryId.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


generateEd25519Addresses

generateEd25519Addresses(amount, options?): Promise<AccountAddress[]>

Generate new unused Ed25519 addresses.

Parameters

NameTypeDescription
amountnumberThe amount of addresses to generate.
options?GenerateAddressOptionsOptions for address generation.

Returns

Promise<AccountAddress[]>

The addresses.


getBalance

getBalance(): Promise<Balance>

Get the account balance.

Returns

Promise<Balance>

The account balance.


getOutput

getOutput(outputId): Promise<OutputData>

Get the data for an output.

Parameters

NameTypeDescription
outputIdstringThe output to get.

Returns

Promise<OutputData>

The OutputData.


getParticipationEvent

getParticipationEvent(eventId): Promise<ParticipationEventWithNodes>

Get a participation event.

Parameters

NameTypeDescription
eventIdstringThe ID of the event to get.

Returns

Promise<ParticipationEventWithNodes>


getParticipationEventIds

getParticipationEventIds(node, eventType?): Promise<string[]>

Get IDs of participation events of a certain type.

Parameters

NameTypeDescription
nodeINodeThe node to get events from.
eventType?ParticipationEventTypeThe type of events to get.

Returns

Promise<string[]>


getParticipationEvents

getParticipationEvents(): Promise<ParticipationEventMap>

Get all participation events.

Returns

Promise<ParticipationEventMap>


getParticipationEventStatus

getParticipationEventStatus(eventId): Promise<ParticipationEventStatus>

Get the participation event status by its ID.

Parameters

NameTypeDescription
eventIdstringThe ID of the event status to get.

Returns

Promise<ParticipationEventStatus>


getFoundryOutput

getFoundryOutput(tokenId): Promise<FoundryOutput>

Get a FoundryOutput by native token ID. It will try to get the foundry from the account, if it isn't in the account it will try to get it from the node.

Parameters

NameTypeDescription
tokenIdstringThe native token ID to get the foundry for.

Returns

Promise<FoundryOutput>

The FoundryOutput that minted the token.


claimableOutputs

claimableOutputs(outputs): Promise<string[]>

Get outputs with additional unlock conditions.

Parameters

NameTypeDescription
outputsOutputsToClaimThe type of outputs to claim.

Returns

Promise<string[]>

The output IDs of the unlockable outputs.


getTransaction

getTransaction(transactionId): Promise<Transaction>

Get a transaction stored in the account.

Parameters

NameTypeDescription
transactionIdstringThe ID of the transaction to get.

Returns

Promise<Transaction>

The transaction.


getIncomingTransaction

getIncomingTransaction(transactionId): Promise<Transaction>

Get the transaction with inputs of an incoming transaction stored in the account List might not be complete, if the node pruned the data already

Parameters

NameTypeDescription
transactionIdstringThe ID of the transaction to get.

Returns

Promise<Transaction>

The transaction.


addresses

addresses(): Promise<AccountAddress[]>

List all the addresses of the account.

Returns

Promise<AccountAddress[]>

The addresses.


addressesWithUnspentOutputs

addressesWithUnspentOutputs(): Promise<AddressWithUnspentOutputs[]>

List the addresses of the account with unspent outputs.

Returns

Promise<AddressWithUnspentOutputs[]>

The addresses.


outputs

outputs(filterOptions?): Promise<OutputData[]>

List all outputs of the account.

Parameters

NameTypeDescription
filterOptions?FilterOptionsOptions to filter the to be returned outputs.

Returns

Promise<OutputData[]>

The outputs with metadata.


pendingTransactions

pendingTransactions(): Promise<Transaction[]>

List all the pending transactions of the account.

Returns

Promise<Transaction[]>

The transactions.


incomingTransactions

incomingTransactions(): Promise<Transaction[]>

List all incoming transactions of the account.

Returns

Promise<Transaction[]>

The incoming transactions with their inputs.


transactions

transactions(): Promise<Transaction[]>

List all the transactions of the account.

Returns

Promise<Transaction[]>

The transactions.


unspentOutputs

unspentOutputs(filterOptions?): Promise<OutputData[]>

List all the unspent outputs of the account.

Parameters

NameTypeDescription
filterOptions?FilterOptionsOptions to filter the to be returned outputs.

Returns

Promise<OutputData[]>

The outputs with metadata.


getMetadata

getMetadata(): AccountMetadata

Get the accounts metadata.

Returns

AccountMetadata

The accounts metadata.


prepareMintNativeToken

prepareMintNativeToken(tokenId, mintAmount, transactionOptions?): Promise<PreparedTransaction>

Mint additional native tokens.

Parameters

NameTypeDescription
tokenIdstringThe native token id.
mintAmountbigintTo be minted amount.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared minting transaction.


prepareCreateNativeToken

prepareCreateNativeToken(params, transactionOptions?): Promise<PreparedCreateNativeTokenTransaction>

Create a native token.

Parameters

NameTypeDescription
paramsCreateNativeTokenParamsThe options for creating a native token.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedCreateNativeTokenTransaction>

The creating transaction and the token ID.


prepareMintNfts

prepareMintNfts(params, transactionOptions?): Promise<PreparedTransaction>

Mint NFTs.

Parameters

NameTypeDescription
paramsMintNftParams[]The options for minting nfts.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared minting transaction.


prepareOutput

prepareOutput(params, transactionOptions?): Promise<Output>

Prepare an output for sending, useful for offline signing.

Parameters

NameTypeDescription
paramsOutputParams-
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<Output>

The prepared output.


prepareSend

prepareSend(params, options?): Promise<PreparedTransaction>

Prepare to send base coins, useful for offline signing.

Parameters

NameTypeDescription
paramsSendParams[]Address with amounts to send.
options?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction data.


prepareTransaction

prepareTransaction(outputs, options?): Promise<PreparedTransaction>

Prepare a transaction, useful for offline signing.

Parameters

NameTypeDescription
outputsOutput[]Outputs to use in the transaction.
options?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction data.


registerParticipationEvents

registerParticipationEvents(options): Promise<ParticipationEventMap>

Register participation events.

Parameters

NameTypeDescription
optionsParticipationEventRegistrationOptionsOptions to register participation events.

Returns

Promise<ParticipationEventMap>

A mapping between event IDs and their corresponding event data.


retryTransactionUntilIncluded

retryTransactionUntilIncluded(transactionId, interval?, maxAttempts?): Promise<string>

Retries (promotes or reattaches) a transaction sent from the account for a provided transaction id until it's included (referenced by a milestone). Returns the included block id.

Parameters

NameType
transactionIdstring
interval?number
maxAttempts?number

Returns

Promise<string>


send

send(amount, address, transactionOptions?): Promise<Transaction>

Send base coins to an address.

Parameters

NameTypeDescription
amountstring | bigintAmount of coins.
addressstringReceiving address.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<Transaction>

The sent transaction.


sendWithParams

sendWithParams(params, transactionOptions?): Promise<Transaction>

Send base coins with amounts from input addresses.

Parameters

NameTypeDescription
paramsSendParams[]Addresses with amounts.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<Transaction>

The sent transaction.


prepareSendNativeTokens

prepareSendNativeTokens(params, transactionOptions?): Promise<PreparedTransaction>

Send native tokens.

Parameters

NameTypeDescription
paramsSendNativeTokensParams[]Addresses amounts and native tokens.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


prepareSendNft

prepareSendNft(params, transactionOptions?): Promise<PreparedTransaction>

Send NFT.

Parameters

NameTypeDescription
paramsSendNftParams[]Addresses and nft ids.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransaction>

The prepared transaction.


sendOutputs

sendOutputs(outputs, transactionOptions?): Promise<Transaction>

Send outputs in a transaction.

Parameters

NameTypeDescription
outputsOutput[]The outputs to send.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<Transaction>

The sent transaction.


setAlias

setAlias(alias): Promise<void>

Set the alias for the account

Parameters

NameTypeDescription
aliasstringThe account alias to set.

Returns

Promise<void>


setDefaultSyncOptions

setDefaultSyncOptions(options): Promise<void>

Set the fallback SyncOptions for account syncing. If storage is enabled, will persist during restarts.

Parameters

NameTypeDescription
optionsSyncOptionsThe sync options to set.

Returns

Promise<void>


signTransactionEssence

signTransactionEssence(preparedTransactionData): Promise<SignedTransactionEssence>

Sign a prepared transaction, useful for offline signing.

Parameters

NameTypeDescription
preparedTransactionDataPreparedTransactionDataThe prepared transaction data to sign.

Returns

Promise<SignedTransactionEssence>

The signed transaction essence.


signAndSubmitTransaction

signAndSubmitTransaction(preparedTransactionData): Promise<Transaction>

Sign a prepared transaction, and send it.

Parameters

NameTypeDescription
preparedTransactionDataPreparedTransactionDataThe prepared transaction data to sign and submit.

Returns

Promise<Transaction>

The transaction.


submitAndStoreTransaction

submitAndStoreTransaction(signedTransactionData): Promise<Transaction>

Validate the transaction, submit it to a node and store it in the account.

Parameters

NameTypeDescription
signedTransactionDataSignedTransactionEssenceA signed transaction to submit and store.

Returns

Promise<Transaction>

The sent transaction.


sync

sync(options?): Promise<Balance>

Sync the account by fetching new information from the nodes. Will also retry pending transactions if necessary. A custom default can be set using setDefaultSyncOptions.

Parameters

NameTypeDescription
options?SyncOptionsOptional synchronization options.

Returns

Promise<Balance>

The account balance.


prepareVote

prepareVote(eventId?, answers?): Promise<PreparedTransaction>

Prepare a vote.

Parameters

NameTypeDescription
eventId?stringThe participation event ID.
answers?number[]Answers for a voting event, can be empty.

Returns

Promise<PreparedTransaction>

An instance of PreparedTransaction.


prepareStopParticipating

prepareStopParticipating(eventId): Promise<PreparedTransaction>

Prepare stop participating in an event.

Parameters

NameTypeDescription
eventIdstringThe event ID to stop participating in.

Returns

Promise<PreparedTransaction>

An instance of PreparedTransaction.


getParticipationOverview

getParticipationOverview(eventIds?): Promise<ParticipationOverview>

Calculates the voting overview of an account.

Parameters

NameTypeDescription
eventIds?string[]Optional, filters participations only for provided events.

Returns

Promise<ParticipationOverview>

An instance of ParticipationOverview


prepareVotingPower

prepareVotingPower(amount): Promise<PreparedTransaction>

Parameters

NameType
amountstring

Returns

Promise<PreparedTransaction>

Deprecated

use prepareIncreaseVotingPower() instead.


prepareIncreaseVotingPower

prepareIncreaseVotingPower(amount): Promise<PreparedTransaction>

Prepare to increase the voting power.

Parameters

NameTypeDescription
amountstringThe amount to increase the voting power by.

Returns

Promise<PreparedTransaction>

An instance of PreparedTransaction.


prepareDecreaseVotingPower

prepareDecreaseVotingPower(amount): Promise<PreparedTransaction>

Prepare to decrease the voting power.

Parameters

NameTypeDescription
amountstringThe amount to decrease the voting power by.

Returns

Promise<PreparedTransaction>

An instance of PreparedTransaction.