Class: Account
The Account class.
Table of contents
Methods
- buildAliasOutput
- buildBasicOutput
- buildFoundryOutput
- buildNftOutput
- prepareBurn
- prepareBurnNativeToken
- prepareBurnNft
- claimOutputs
- prepareConsolidateOutputs
- prepareCreateAliasOutput
- prepareMeltNativeToken
- prepareDestroyAlias
- prepareDestroyFoundry
- generateEd25519Addresses
- getBalance
- getOutput
- getFoundryOutput
- claimableOutputs
- getTransaction
- getIncomingTransaction
- addresses
- addressesWithUnspentOutputs
- outputs
- pendingTransactions
- incomingTransactions
- transactions
- unspentOutputs
- getMetadata
- minimumRequiredStorageDeposit
- prepareMintNativeToken
- prepareCreateNativeToken
- prepareMintNfts
- prepareOutput
- prepareSendAmount
- prepareTransaction
- retryTransactionUntilIncluded
- sendAmount
- prepareSendNativeTokens
- prepareSendNft
- sendOutputs
- setAlias
- setDefaultSyncOptions
- signTransactionEssence
- signAndSubmitTransaction
- submitAndStoreTransaction
- sync
- getParticipationOverview
Methods
buildAliasOutput
▸ buildAliasOutput(data
): Promise
<IAliasOutput
>
Build an AliasOutput
.
Parameters
Name | Type | Description |
---|---|---|
data | BuildAliasOutputData | Options for building an AliasOutput . |
Returns
Promise
<IAliasOutput
>
The built AliasOutput
.
buildBasicOutput
▸ buildBasicOutput(data
): Promise
<IBasicOutput
>
Build a BasicOutput
.
Parameters
Name | Type | Description |
---|---|---|
data | BuildBasicOutputData | Options for building a BasicOutput . |
Returns
Promise
<IBasicOutput
>
The built BasicOutput
.
buildFoundryOutput
▸ buildFoundryOutput(data
): Promise
<IFoundryOutput
>
Build a FoundryOutput
.
Parameters
Name | Type | Description |
---|---|---|
data | BuildFoundryOutputData | Options for building a FoundryOutput . |
Returns
Promise
<IFoundryOutput
>
The built FoundryOutput
.
buildNftOutput
▸ buildNftOutput(data
): Promise
<NftOutput
>
Build an NftOutput
.
Parameters
Name | Type | Description |
---|---|---|
data | BuildNftOutputData | Options 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
Name | Type | Description |
---|---|---|
burn | Burn | The outputs to burn |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
tokenId | string | The native token id. |
burnAmount | string | The to be burned amount. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<PreparedTransactionData
>
The transaction.
prepareBurnNft
▸ prepareBurnNft(nftId
, transactionOptions?
): Promise
<PreparedTransactionData
>
Burn an nft output.
Parameters
Name | Type | Description |
---|---|---|
nftId | string | The NftId. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
outputIds | string [] | 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
Name | Type | Description |
---|---|---|
force | boolean | Force consolidation on addresses where the threshold isn't met. |
outputConsolidationThreshold? | number | A 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
Name | Type | Description |
---|---|---|
params? | AliasOutputParams | The alias output options. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
aliasId | string | The AliasId. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
foundryId | string | The FoundryId. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
amount | number | The amount of addresses to generate. |
options? | GenerateAddressOptions | Options 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
Name | Type | Description |
---|---|---|
outputId | string | The 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
Name | Type | Description |
---|---|---|
tokenId | string | The 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
Name | Type | Description |
---|---|---|
outputs | OutputsToClaim | The 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
Name | Type | Description |
---|---|---|
transactionId | string | The 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
Name | Type | Description |
---|---|---|
transactionId | string | The 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
Name | Type | Description |
---|---|---|
filterOptions? | FilterOptions | Options 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
Name | Type | Description |
---|---|---|
filterOptions? | FilterOptions | Options to filter the to be returned outputs. |
Returns
Promise
<OutputData
[]>
The outputs with metadata.
getMetadata
▸ getMetadata(): AccountMetadata
Get the accounts metadata.
Returns
The accounts metadata.
minimumRequiredStorageDeposit
▸ minimumRequiredStorageDeposit(output
): Promise
<string
>
Calculate the minimum required storage deposit for an output.
Parameters
Name | Type | Description |
---|---|---|
output | Output | output to calculate the deposit amount for. |
Returns
Promise
<string
>
The amount.
prepareCreateNativeToken
▸ prepareCreateNativeToken(params
, transactionOptions?
): Promise
<PreparedCreateNativeTokenTransactionData
>
Create a native token.
Parameters
Name | Type | Description |
---|---|---|
params | CreateNativeTokenParams | The options for creating tokens. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
tokenId | string | The native token id. |
mintAmount | string | To be minted amount. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
tokenId | string | The native token id. |
meltAmount | string | To be melted amount. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<PreparedTransactionData
>
The melting transaction.
prepareMintNfts
▸ prepareMintNfts(params
, transactionOptions?
): Promise
<PreparedTransactionData
>
Mint nfts.
Parameters
Name | Type | Description |
---|---|---|
params | MintNftParams [] | The options for minting nfts. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
params | OutputParams | - |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
params | SendAmountParams [] | Address with amounts to send. |
options? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
outputs | Output [] | Outputs to use in the transaction. |
options? | TransactionOptions | The 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
Name | Type |
---|---|
transactionId | string |
interval? | number |
maxAttempts? | number |
Returns
Promise
<string
>
sendAmount
▸ sendAmount(params
, transactionOptions?
): Promise
<Transaction
>
Send a transaction with amounts from input addresses.
Parameters
Name | Type | Description |
---|---|---|
params | SendAmountParams [] | Addresses with amounts. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<Transaction
>
The sent transaction.
prepareSendNativeTokens
▸ prepareSendNativeTokens(params
, transactionOptions?
): Promise
<PreparedTransactionData
>
Send native tokens.
Parameters
Name | Type | Description |
---|---|---|
params | SendNativeTokensParams [] | Addresses amounts and native tokens. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<PreparedTransactionData
>
The sent transaction.
prepareSendNft
▸ prepareSendNft(params
, transactionOptions?
): Promise
<PreparedTransactionData
>
Send nft.
Parameters
Name | Type | Description |
---|---|---|
params | SendNftParams [] | Addresses and nft ids. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
outputs | Output [] | The outputs to send. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
alias | string | The 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
Name | Type | Description |
---|---|---|
options | SyncOptions | The sync options to set. |
Returns
Promise
<void
>
signTransactionEssence
▸ signTransactionEssence(preparedTransactionData
): Promise
<SignedTransactionEssence
>
Sign a prepared transaction, useful for offline signing.
Parameters
Name | Type | Description |
---|---|---|
preparedTransactionData | IPreparedTransactionData | The 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
Name | Type | Description |
---|---|---|
preparedTransactionData | IPreparedTransactionData | The 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
Name | Type | Description |
---|---|---|
signedTransactionData | SignedTransactionEssence | A 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
Name | Type | Description |
---|---|---|
options? | SyncOptions | Optional synchronization options. |
Returns
Promise
<Balance
>
The account balance.
getParticipationOverview
▸ getParticipationOverview(eventIds?
): Promise
<ParticipationOverview
>
Calculates the voting overview of an account.
Parameters
Name | Type | Description |
---|---|---|
eventIds? | string [] | Optional, filters participations only for provided events. |
Returns
Promise
<ParticipationOverview
>
ParticipationOverview