Skip to main content

Class: Account

The Account class.

Table of contents

Methods

Methods

buildAliasOutput

buildAliasOutput(data): Promise<IAliasOutput>

Build an AliasOutput.

Parameters

NameTypeDescription
dataBuildAliasOutputDataOptions for building an AliasOutput.

Returns

Promise<IAliasOutput>

The built AliasOutput.


buildBasicOutput

buildBasicOutput(data): Promise<IBasicOutput>

Build a BasicOutput.

Parameters

NameTypeDescription
dataBuildBasicOutputDataOptions for building a BasicOutput.

Returns

Promise<IBasicOutput>

The built BasicOutput.


buildFoundryOutput

buildFoundryOutput(data): Promise<IFoundryOutput>

Build a FoundryOutput.

Parameters

NameTypeDescription
dataBuildFoundryOutputDataOptions for building a FoundryOutput.

Returns

Promise<IFoundryOutput>

The built FoundryOutput.


buildNftOutput

buildNftOutput(data): Promise<NftOutput>

Build an NftOutput.

Parameters

NameTypeDescription
dataBuildNftOutputDataOptions for building an NftOutput.

Returns

Promise<NftOutput>

The built NftOutput.


prepareBurn

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

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<Transaction>

The resulting transaction.


prepareBurnNativeToken

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

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.
burnAmountstringThe to be burned amount.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransactionData>

The transaction.


prepareBurnNft

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

Burn an nft output.

Parameters

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

Returns

Promise<PreparedTransactionData>

The 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(force, outputConsolidationThreshold?): Promise<PreparedTransactionData>

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

NameTypeDescription
forcebooleanForce consolidation on addresses where the threshold isn't met.
outputConsolidationThreshold?numberA default threshold is used if this is omitted.

Returns

Promise<PreparedTransactionData>

The consolidation transaction.


prepareCreateAliasOutput

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

createAliasOutput creates an alias output

Parameters

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

Returns

Promise<PreparedTransactionData>

A transaction object.


prepareDestroyAlias

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

Destroy an alias output.

Parameters

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

Returns

Promise<PreparedTransactionData>

The transaction.


prepareDestroyFoundry

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

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<PreparedTransactionData>

The 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.


getFoundryOutput

getFoundryOutput(tokenId): Promise<IFoundryOutput>

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<IFoundryOutput>

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.


minimumRequiredStorageDeposit

minimumRequiredStorageDeposit(output): Promise<string>

Calculate the minimum required storage deposit for an output.

Parameters

NameTypeDescription
outputOutputoutput to calculate the deposit amount for.

Returns

Promise<string>

The amount.


prepareCreateNativeToken

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

Create a native token.

Parameters

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

Returns

Promise<PreparedCreateNativeTokenTransactionData>

The creating transaction and the token ID.


prepareMintNativeToken

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

Mint additional native tokens.

Parameters

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

Returns

Promise<PreparedTransactionData>

The minting transaction.


prepareMeltNativeToken

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

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

Parameters

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

Returns

Promise<PreparedTransactionData>

The melting transaction.


prepareMintNfts

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

Mint nfts.

Parameters

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

Returns

Promise<PreparedTransactionData>

The 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.


prepareSendAmount

prepareSendAmount(params, options?): Promise<PreparedTransactionData>

Prepare a send amount transaction, useful for offline signing.

Parameters

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

Returns

Promise<PreparedTransactionData>

The prepared transaction data.


prepareTransaction

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

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<PreparedTransactionData>

The prepared transaction 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>


sendAmount

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

Send a transaction with amounts from input addresses.

Parameters

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

Returns

Promise<Transaction>

The sent transaction.


prepareSendNativeTokens

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

Send native tokens.

Parameters

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

Returns

Promise<PreparedTransactionData>

The sent transaction.


prepareSendNft

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

Send nft.

Parameters

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

Returns

Promise<PreparedTransactionData>

The sent 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
preparedTransactionDataIPreparedTransactionDataThe 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
preparedTransactionDataIPreparedTransactionDataThe 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.


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>

ParticipationOverview