Construct a new instance of the UserClient class from the given configuration. This will use the default representatives for the network based on the configuration.
New instances should be cleaned up with the destroy method when they are no longer needed.
The recommended way to create a new instance of the UserClient class is to use the fromNetwork method.
Readonly
baseThe base token for the network this client is connected to.
Readonly
networkThe network address for the network this client is connected to.
Static
Readonly
ConfigReference to the Config class for the client. This is used to access the Configuration operations which may be needed for the UserClient.
Static
isDetermine if a given object is an instance of the UserClient class.
This is preferred over using instanceof
because it works across
different contexts.
Get the account for this instance. This is the account that will be affected by the blocks and transactions that are published.
Get the configuration for this UserClient instance.
Get the network ID for this instance. This is the network that this instance is connected to.
Whether or not this client is "readonly". This is true if the signer is null.
Get the signer for this instance, if it was set. This is the account that will be used to sign blocks and transactions. If this is null, then the client is readonly and will not be able to publish blocks or transactions.
Get all the balances for the given account. See Client.getAllBalances for more information.
The options to use for the request
The balances for the account
Get the balance for a given token for the given account. See Client.getBalance for more information.
The token to get the balance for
The options to use for the request
The balance for the account of the given token
Get the chain for the given account. This will return the chain as Client.getChain does.
Optional
query: { depth?: number; startBlock?: string | BlockHash }The query to use for the chain
The options to use for the request
The chain for the account, paginated
Compute the blocks needed to publish a given builder. This will update the state of the builder and any new operations added after this will generate new blocks.
The builder to compute the blocks for
The blocks that were computed
Use UserClientBuilder.computeBlocks instead
Destroy this instance -- this is required to clean up all resources.
Filter the given vote staples for the user client account. See UserClient.filterStapleOperations for more information.
The vote staples to filter
The options to use for the request
The filtered operations for the given account, ordered by vote staple hash, then by block, and then containing each operation
Generate a new identifier for the given type and publish the blocks
The type of identifier to generate
The options to use for the request
The identifier that was generated
Get the current head block for the given account. This will return the hash of the current head block for the account or null if the account has no blocks.
The options to use for the request
The hash of the current head block for the account or null if the account has no blocks
Get the history for the given account. This will return the history as Client.getHistory does.
Optional
query: { depth?: number; startBlocksHash?: string | VoteBlockHash }The query to use for the history
The options to use for the request
The history for the account, paginated
Create a new UserClientBuilder instance for this client. This is used to create a new builder for adding operations to which are then converted into the appropriate set of blocks.
The options to use for the builder
A new UserClientBuilder instance
Generate and publish the blocks needed to initialize a new network with the given parameters.
This is generally only needed once per network and is used to initialize the network with a base token and a representative in order to start-up the network.
The options to use for the initialization
The amount of supply to add to the network of the base token
Optional
delegateTo?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>The representative account to delegate the supply to
Optional
voteSerial?: bigintThe serial number to use for the vote -- must never be reused by the representative
The options to use for the request
The vote staple that was generated and whether it was able to be published
List ACLs for the given account. This will return the ACLs the account has set. See Client.listACLsByEntity for more information.
The options to use for the request
The ACLs for the account
List ACLs for the given account. This will return the ACLs that relate to specified entities. See Client.listACLsByPrincipal for more information.
The list of entities to get the ACLs for
The options to use for the request
The ACLs for the account
List ACLs that others have set for the given account. See Client.listACLsByEntity for more information.
The options to use for the request
The ACLs applied for the account
Modify both the token supply (mint/burn) and account balance for a given account of a given token.
This will mint if a positive amount is given and burn if a negative amount is given, and the add or subtract the same amount from the account balance.
The amount to add or subtract from the token supply and account balance
The token to modify the supply and balance for
The options to use for the request
The vote staple that was generated and whether it was able to be published
Register a callback for change messages and set up a websocket filtered to our account only. Also set up long timeout polling for changes in case the websocket misses a change update Check that parameters of function complies with respective event function
Get the pending block for the given account. This will return any side-ledger block for that account, or null if there is no pending block.
The options to use for the request
The pending block for the account or null if there is no pending block
Compute the blocks needed to publish a given builder and then publish those blocks to the network. The builder should generally not be used after this method is called as the blocks will be published and the builder will be in an invalid state.
In general, the UserClientBuilder.publish method should be used instead of this one.
The builder to publish
The vote staple that was generated and whether it was able to be published
Recover any unpublished or half-publish account artifacts
Optional
publish: booleanPublish the recovered staple to the network (default: true)
User client options (common options)
Send some tokens from this account to another account.
If an external
identifier is provided, it will be included in the
Send operation and can be used by the recipient to identify the
transaction.
The account to send the tokens to
The amount of tokens to send (in base units)
The token to send
Optional
external: stringThe external identifier to use for the transaction
The options to use for the request
The number of times to retry the request if it fails
The vote staple that was generated and whether it was able to be published
Set the metadata for an account and publish the blocks to the network.
The account info to set
The options to use for the request
The vote staple that was generated and whether it was able to be published
Get the current live state of the account. This will return the current state of the account as Client.getAccountInfo does.
The options to use for the request
The current state of the account
Update the permissions for a given account. This will publish the changes to the network.
The account to update the permissions regarding for this account
The permissions to set for the account
Optional
target: string | GenericAccountThe account to set the permissions for, if applicable for this permission
Optional
method: AdjustMethodThe method to use for the permission, defaults to SET
The options to use for the request
The vote staple that was generated and whether it was able to be published
Static
filterHelper method to filter a list of vote staples into a list of blocks and operations that are related to a given account.
The list of vote staples to filter
The account to search for operations related to
An array of filtered operations for the given account, ordered by vote staple hash, then by block, and then containing each operation
Static
fromConstruct a new instance of the UserClient class from the given network name. This will use the default representatives for the network based on the configuration.
New instances should be cleaned up with the destroy() method when they are no longer needed.
This is the recommended way to create a new instance of the UserClient class.
The network to use for this instance of the UserClient class
The account to use for this instance of the UserClient class, or null if this is a read-only client
Optional
options: UserClientOptionsThe options to use for this instance of the UserClient class
Optional
account?: GenericAccountThe account to use for the user client, if this is not supplied then
the signer
will be used (if available) otherwise this there will
be no account and some operations may not be available.
Optional
publishAidURL?: stringIf using the publish aid (see ['usePublishAid']) the URL to use.
The default depends on the network configuration.
Optional
usePublishAid?: booleanUse the "publish aid" service to publish blocks.
This service handles requesting short votes and permanent votes and publishing to the network. This can reduce latency for clients far away from representatives because they only need to wait for a single response instead of multiple round-trips.
The default is false.
A new instance of the UserClient class
Static
fromCreate an instance of the UserClient class from a specific representative. This will use the given representative to initialize the connection to the network, however it will find other representatives to use for the network as well.
This is useful for testing and development purposes, but in general it is recommended to use the fromNetwork method to create a new instance of the UserClient class.
Optional
options: UserClientOptionsStatic
getA helper method to get the configuration from the network alias and options. This will use the default representatives for the network based on the configuration.
The network to use to generate the configuration
Optional
options: UserClientOptionsThe options to use to generate the configuration
The configuration object for the UserClient class
The UserClient class provides a high-level interface, user-oriented interface to the Keeta network. It is designed to be easy to use and handle the most common cases for applications building on top of the Keeta network.
Example