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

Build an NftOutput.

Parameters

NameTypeDescription
dataBuildNftOutputDataOptions for building an NftOutput.

Returns

Promise<INftOutput>

The built NftOutput.


burnNativeToken

burnNativeToken(tokenId, burnAmount, transactionOptions?): Promise<Transaction>

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

The transaction.


burnNft

burnNft(nftId, transactionOptions?): Promise<Transaction>

Burn an nft output. Outputs controlled by it will be sweeped before if they don't have a storage deposit return, timelock or expiration unlock condition. This should be preferred over burning, because after burning, the foundry can never be destroyed anymore.

Parameters

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

Returns

Promise<Transaction>

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.


consolidateOutputs

consolidateOutputs(force, outputConsolidationThreshold?): Promise<Transaction>

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

The consolidation transaction.


createAliasOutput

createAliasOutput(aliasOutputOptions?, transactionOptions?): Promise<Transaction>

createAliasOutput creates an alias output

Parameters

NameTypeDescription
aliasOutputOptions?AliasOutputOptionsThe alias output options.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<Transaction>

A transaction object.


decreaseNativeTokenSupply

decreaseNativeTokenSupply(tokenId, meltAmount, transactionOptions?): Promise<Transaction>

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

The transaction.


destroyAlias

destroyAlias(aliasId, transactionOptions?): Promise<Transaction>

Destroy an alias output. Outputs controlled by it will be sweeped before if they don't have a storage deposit return, timelock or expiration unlock condition. The amount and possible native tokens will be sent to the governor address.

Parameters

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

Returns

Promise<Transaction>

The transaction.


destroyFoundry

destroyFoundry(foundryId, transactionOptions?): Promise<Transaction>

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

Parameters

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

Returns

Promise<Transaction>

The transaction.


generateAddress

generateAddress(options?): Promise<Address>

Generate a new unused address.

Parameters

NameTypeDescription
options?AddressGenerationOptionsOptions for address generation.

Returns

Promise<Address>

The address.


generateAddresses

generateAddresses(amount, options?): Promise<Address[]>

Generate new unused addresses.

Parameters

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

Returns

Promise<Address[]>

The addresses.


getBalance

getBalance(): Promise<AccountBalance>

Get the account balance.

Returns

Promise<AccountBalance>

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.


getOutputsWithAdditionalUnlockConditions

getOutputsWithAdditionalUnlockConditions(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.


getIncomingTransactionData

getIncomingTransactionData(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<Address[]>

List all the addresses of the account.

Returns

Promise<Address[]>

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<[string, Transaction][]>

List all incoming transactions of the account.

Returns

Promise<[string, 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
outputOutputTypesoutput to calculate the deposit amount for.

Returns

Promise<string>

The amount.


increaseNativeTokenSupply

increaseNativeTokenSupply(tokenId, mintAmount, increaseNativeTokenSupplyOptions?, transactionOptions?): Promise<MintTokenTransaction>

Mint more native tokens.

Parameters

NameTypeDescription
tokenIdstringThe native token id.
mintAmountstringTo be minted amount.
increaseNativeTokenSupplyOptions?IncreaseNativeTokenSupplyOptionsOptions for minting more tokens.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<MintTokenTransaction>

The minting transaction and the token ID.


mintNativeToken

mintNativeToken(nativeTokenOptions, transactionOptions?): Promise<MintTokenTransaction>

Mint native tokens.

Parameters

NameTypeDescription
nativeTokenOptionsNativeTokenOptionsThe options for minting tokens.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<MintTokenTransaction>

The minting transaction and the token ID.


mintNfts

mintNfts(nftsOptions, transactionOptions?): Promise<Transaction>

Mint nfts.

Parameters

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

Returns

Promise<Transaction>

The minting transaction.


prepareOutput

prepareOutput(options, transactionOptions?): Promise<OutputTypes>

Prepare an output for sending, useful for offline signing.

Parameters

NameTypeDescription
optionsOutputOptionsThe options for preparing an output. If the amount is below the minimum required storage deposit, by default the remaining amount will automatically be added with a StorageDepositReturn UnlockCondition, when setting the ReturnStrategy to gift, the full minimum required storage deposit will be sent to the recipient. When the assets contain an nft id, the data from the existing NftOutput will be used, just with the address unlock conditions replaced.
transactionOptions?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<OutputTypes>

The prepared output.


prepareSendAmount

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

Prepare a send amount transaction, useful for offline signing.

Parameters

NameTypeDescription
addressesWithAmountAddressWithAmount[]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
outputsOutputTypes[]Outputs to use in the transaction.
options?TransactionOptionsThe options to define a RemainderValueStrategy or custom inputs.

Returns

Promise<PreparedTransactionData>

The prepared transaction data.


requestFundsFromFaucet

requestFundsFromFaucet(url, address): Promise<string>

Request funds from a faucet.

Parameters

NameType
urlstring
addressstring

Returns

Promise<string>


retryTransactionUntilIncluded

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

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


sendAmount

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

Send a transaction with amounts from input addresses.

Parameters

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

Returns

Promise<Transaction>

The sent transaction.


sendMicroTransaction

sendMicroTransaction(addressesWithMicroAmount, transactionOptions?): Promise<Transaction>

Send a micro transaction with amount below minimum storage deposit.

Parameters

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

Returns

Promise<Transaction>

The sent transaction.


sendNativeTokens

sendNativeTokens(addressesNativeTokens, transactionOptions?): Promise<Transaction>

Send native tokens.

Parameters

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

Returns

Promise<Transaction>

The sent transaction.


sendNft

sendNft(addressesAndNftIds, transactionOptions?): Promise<Transaction>

Send nft.

Parameters

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

Returns

Promise<Transaction>

The sent transaction.


sendOutputs

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

Send outputs in a transaction.

Parameters

NameTypeDescription
outputsOutputTypes[]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>


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.


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

Sync the account by fetching new information from the nodes. Will also retry pending transactions if necessary.

Parameters

NameTypeDescription
options?SyncOptionsOptional synchronization options.

Returns

Promise<AccountBalance>

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