Class: Account
The Account class.
Table of contents
Methods
- buildAliasOutput
- buildBasicOutput
- buildFoundryOutput
- buildNftOutput
- burnNativeToken
- burnNft
- claimOutputs
- consolidateOutputs
- createAliasOutput
- decreaseNativeTokenSupply
- destroyAlias
- destroyFoundry
- generateAddress
- generateAddresses
- getBalance
- getOutput
- getFoundryOutput
- getOutputsWithAdditionalUnlockConditions
- getTransaction
- getIncomingTransactionData
- addresses
- addressesWithUnspentOutputs
- outputs
- pendingTransactions
- incomingTransactions
- transactions
- unspentOutputs
- getMetadata
- minimumRequiredStorageDeposit
- increaseNativeTokenSupply
- mintNativeToken
- mintNfts
- prepareOutput
- prepareSendAmount
- prepareTransaction
- requestFundsFromFaucet
- retryTransactionUntilIncluded
- sendAmount
- sendMicroTransaction
- sendNativeTokens
- sendNft
- sendOutputs
- setAlias
- signTransactionEssence
- 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
<INftOutput
>
Build an NftOutput
.
Parameters
Name | Type | Description |
---|---|---|
data | BuildNftOutputData | Options 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
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
<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
Name | Type | Description |
---|---|---|
nftId | string | The NftId. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
outputIds | string [] | 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
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
<Transaction
>
The consolidation transaction.
createAliasOutput
▸ createAliasOutput(aliasOutputOptions?
, transactionOptions?
): Promise
<Transaction
>
createAliasOutput
creates an alias output
Parameters
Name | Type | Description |
---|---|---|
aliasOutputOptions? | AliasOutputOptions | The alias output options. |
transactionOptions? | TransactionOptions | The 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
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
<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
Name | Type | Description |
---|---|---|
aliasId | string | The AliasId. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
foundryId | string | The FoundryId. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<Transaction
>
The transaction.
generateAddress
▸ generateAddress(options?
): Promise
<Address
>
Generate a new unused address.
Parameters
Name | Type | Description |
---|---|---|
options? | AddressGenerationOptions | Options for address generation. |
Returns
Promise
<Address
>
The address.
generateAddresses
▸ generateAddresses(amount
, options?
): Promise
<Address
[]>
Generate new unused addresses.
Parameters
Name | Type | Description |
---|---|---|
amount | number | The amount of addresses to generate. |
options? | AddressGenerationOptions | Options 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
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.
getOutputsWithAdditionalUnlockConditions
▸ getOutputsWithAdditionalUnlockConditions(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.
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
Name | Type | Description |
---|---|---|
transactionId | string | The 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
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
<[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
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 | OutputTypes | output to calculate the deposit amount for. |
Returns
Promise
<string
>
The amount.
increaseNativeTokenSupply
▸ increaseNativeTokenSupply(tokenId
, mintAmount
, increaseNativeTokenSupplyOptions?
, transactionOptions?
): Promise
<MintTokenTransaction
>
Mint more native tokens.
Parameters
Name | Type | Description |
---|---|---|
tokenId | string | The native token id. |
mintAmount | string | To be minted amount. |
increaseNativeTokenSupplyOptions? | IncreaseNativeTokenSupplyOptions | Options for minting more tokens. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
nativeTokenOptions | NativeTokenOptions | The options for minting tokens. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
nftsOptions | NftOptions [] | The options for minting nfts. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
options | OutputOptions | The 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? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
addressesWithAmount | AddressWithAmount [] | 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 | OutputTypes [] | Outputs to use in the transaction. |
options? | TransactionOptions | The 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
Name | Type |
---|---|
url | string |
address | string |
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
Name | Type |
---|---|
transactionId | string |
interval? | number |
maxAttempts? | number |
Returns
Promise
<PreparedTransactionData
>
sendAmount
▸ sendAmount(addressesWithAmount
, transactionOptions?
): Promise
<Transaction
>
Send a transaction with amounts from input addresses.
Parameters
Name | Type | Description |
---|---|---|
addressesWithAmount | AddressWithAmount [] | Addresses with amounts. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
addressesWithMicroAmount | AddressWithMicroAmount [] | Addresses with micro amounts. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<Transaction
>
The sent transaction.
sendNativeTokens
▸ sendNativeTokens(addressesNativeTokens
, transactionOptions?
): Promise
<Transaction
>
Send native tokens.
Parameters
Name | Type | Description |
---|---|---|
addressesNativeTokens | AddressNativeTokens [] | Addresses amounts and native tokens. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise
<Transaction
>
The sent transaction.
sendNft
▸ sendNft(addressesAndNftIds
, transactionOptions?
): Promise
<Transaction
>
Send nft.
Parameters
Name | Type | Description |
---|---|---|
addressesAndNftIds | AddressNftId [] | Addresses and nft ids. |
transactionOptions? | TransactionOptions | The 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
Name | Type | Description |
---|---|---|
outputs | OutputTypes [] | 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
>
signTransactionEssence
▸ signTransactionEssence(preparedTransactionData
): Promise
<SignedTransactionEssence
>
Sign a prepared transaction, useful for offline signing.
Parameters
Name | Type | Description |
---|---|---|
preparedTransactionData | PreparedTransactionData | The 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
Name | Type | Description |
---|---|---|
signedTransactionData | SignedTransactionEssence | A 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
Name | Type | Description |
---|---|---|
options? | SyncOptions | Optional synchronization options. |
Returns
Promise
<AccountBalance
>
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