Class: Account
The Account class.
Table of contents
Constructors
Methods
- buildAliasOutput
- buildBasicOutput
- buildFoundryOutput
- buildNftOutput
- prepareBurn
- prepareBurnNativeToken
- prepareBurnNft
- claimOutputs
- prepareConsolidateOutputs
- prepareCreateAliasOutput
- prepareMeltNativeToken
- deregisterParticipationEvent
- prepareDestroyAlias
- prepareDestroyFoundry
- generateEd25519Addresses
- getBalance
- getOutput
- getParticipationEvent
- getParticipationEventIds
- getParticipationEvents
- getParticipationEventStatus
- getFoundryOutput
- claimableOutputs
- getTransaction
- getIncomingTransaction
- addresses
- addressesWithUnspentOutputs
- outputs
- pendingTransactions
- incomingTransactions
- transactions
- unspentOutputs
- getMetadata
- prepareMintNativeToken
- prepareCreateNativeToken
- prepareMintNfts
- prepareOutput
- prepareSend
- prepareTransaction
- registerParticipationEvents
- retryTransactionUntilIncluded
- send
- sendWithParams
- prepareSendNativeTokens
- prepareSendNft
- sendOutputs
- setAlias
- setDefaultSyncOptions
- signTransactionEssence
- signAndSubmitTransaction
- submitAndStoreTransaction
- sync
- prepareVote
- prepareStopParticipating
- getParticipationOverview
- prepareVotingPower
- prepareIncreaseVotingPower
- prepareDecreaseVotingPower
Constructors
constructor
• new Account(accountMeta, methodHandler)
Parameters
| Name | Type | Description |
|---|---|---|
accountMeta | AccountMeta | An instance of AccountMeta. |
methodHandler | WalletMethodHandler | A instance of WalletMethodHandler. |
Methods
buildAliasOutput
▸ buildAliasOutput(data): Promise<AliasOutput>
Parameters
| Name | Type |
|---|---|
data | BuildAliasOutputData |
Returns
Promise<AliasOutput>
Deprecated
use Client::buildAliasOutput() instead.
buildBasicOutput
▸ buildBasicOutput(data): Promise<BasicOutput>
Parameters
| Name | Type |
|---|---|
data | BuildBasicOutputData |
Returns
Promise<BasicOutput>
Deprecated
use Client::buildBasicOutput() instead.
buildFoundryOutput
▸ buildFoundryOutput(data): Promise<FoundryOutput>
Parameters
| Name | Type |
|---|---|
data | BuildFoundryOutputData |
Returns
Promise<FoundryOutput>
Deprecated
use Client::buildFoundryOutput() instead.
buildNftOutput
▸ buildNftOutput(data): Promise<NftOutput>
Parameters
| Name | Type |
|---|---|
data | BuildNftOutputData |
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
| Name | Type | Description |
|---|---|---|
burn | Burn | The outputs to burn |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
tokenId | string | The native token id. |
burnAmount | bigint | The to be burned amount. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
nftId | string | The NftId. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
outputIds | string[] | 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
| Name | Type |
|---|---|
params | ConsolidationParams |
Returns
Promise<PreparedTransaction>
The prepared consolidation transaction.
prepareCreateAliasOutput
▸ prepareCreateAliasOutput(params?, transactionOptions?): Promise<PreparedTransaction>
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<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
| Name | Type | Description |
|---|---|---|
tokenId | string | The native token id. |
meltAmount | bigint | To be melted amount. |
transactionOptions? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise<PreparedTransaction>
The prepared transaction.
deregisterParticipationEvent
▸ deregisterParticipationEvent(eventId): Promise<void>
Deregister a participation event.
Parameters
| Name | Type | Description |
|---|---|---|
eventId | string | The id of the participation event to deregister. |
Returns
Promise<void>
prepareDestroyAlias
▸ prepareDestroyAlias(aliasId, transactionOptions?): Promise<PreparedTransaction>
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<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
| Name | Type | Description |
|---|---|---|
foundryId | string | The FoundryId. |
transactionOptions? | TransactionOptions | The 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
| 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.
getParticipationEvent
▸ getParticipationEvent(eventId): Promise<ParticipationEventWithNodes>
Get a participation event.
Parameters
| Name | Type | Description |
|---|---|---|
eventId | string | The 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
| Name | Type | Description |
|---|---|---|
node | INode | The node to get events from. |
eventType? | ParticipationEventType | The 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
| Name | Type | Description |
|---|---|---|
eventId | string | The 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
| Name | Type | Description |
|---|---|---|
tokenId | string | The 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
| 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.
prepareMintNativeToken
▸ prepareMintNativeToken(tokenId, mintAmount, transactionOptions?): Promise<PreparedTransaction>
Mint additional native tokens.
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | string | The native token id. |
mintAmount | bigint | To be minted amount. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
params | CreateNativeTokenParams | The options for creating a native token. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
params | MintNftParams[] | The options for minting nfts. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
params | OutputParams | - |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
params | SendParams[] | Address with amounts to send. |
options? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
outputs | Output[] | Outputs to use in the transaction. |
options? | TransactionOptions | The options to define a RemainderValueStrategy or custom inputs. |
Returns
Promise<PreparedTransaction>
The prepared transaction data.
registerParticipationEvents
▸ registerParticipationEvents(options): Promise<ParticipationEventMap>
Register participation events.
Parameters
| Name | Type | Description |
|---|---|---|
options | ParticipationEventRegistrationOptions | Options 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
| Name | Type |
|---|---|
transactionId | string |
interval? | number |
maxAttempts? | number |
Returns
Promise<string>
send
▸ send(amount, address, transactionOptions?): Promise<Transaction>
Send base coins to an address.
Parameters
| Name | Type | Description |
|---|---|---|
amount | string | bigint | Amount of coins. |
address | string | Receiving address. |
transactionOptions? | TransactionOptions | The 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
| Name | Type | Description |
|---|---|---|
params | SendParams[] | 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<PreparedTransaction>
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<PreparedTransaction>
The prepared transaction.
prepareSendNft
▸ prepareSendNft(params, transactionOptions?): Promise<PreparedTransaction>
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<PreparedTransaction>
The prepared 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 | PreparedTransactionData | 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 | PreparedTransactionData | 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.
prepareVote
▸ prepareVote(eventId?, answers?): Promise<PreparedTransaction>
Prepare a vote.
Parameters
| Name | Type | Description |
|---|---|---|
eventId? | string | The 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
| Name | Type | Description |
|---|---|---|
eventId | string | The 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
| Name | Type | Description |
|---|---|---|
eventIds? | string[] | Optional, filters participations only for provided events. |
Returns
Promise<ParticipationOverview>
An instance of ParticipationOverview
prepareVotingPower
▸ prepareVotingPower(amount): Promise<PreparedTransaction>
Parameters
| Name | Type |
|---|---|
amount | string |
Returns
Promise<PreparedTransaction>
Deprecated
use prepareIncreaseVotingPower() instead.
prepareIncreaseVotingPower
▸ prepareIncreaseVotingPower(amount): Promise<PreparedTransaction>
Prepare to increase the voting power.
Parameters
| Name | Type | Description |
|---|---|---|
amount | string | The 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
| Name | Type | Description |
|---|---|---|
amount | string | The amount to decrease the voting power by. |
Returns
Promise<PreparedTransaction>
An instance of PreparedTransaction.