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.
ReadonlybaseThe base token for the network this client is connected to.
Indication of whether or not this client has been destroyed.
ReadonlynetworkThe network address for the network this client is connected to.
Static ReadonlyConfigReference to the Config class for the client. This is used to access the Configuration operations which may be needed for the UserClient.
StaticisDetermine 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.
This enables the use of using to automatically clean up the
instance of the UserClient class when it is no longer
needed.
It calls the destroy() method to clean up the instance when it goes out of scope.
Finalize a swap request
AcceptSwapRequest initial swap request block and optional expected token and amounts
OptionalbuilderOrOptions: UserClientOptions | UserClientBuilderUserClientBuilder or UserClientOptions to use for building the swap block
Blocks
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.
Optionalquery: {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
Initiate a swap request
CreateSwapRequest Defines what is being sent from Account, TokenAddress and Amount Defines what is being received from Account, TokenAddress and Converted Amount
Optionaloptions: UserClientOptionsUser client options (common options)
Swap Block
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
Fetch a block from a given idempotent key
The idempotent key to check
User client options (common options)
Get a single certificate for the account, by the certificate hash.
The hash of the certificate to get, or a CertificateHash instance.
Optionaloptions: UserClientOptionsThe options to use for the request
The found certificate, or null if no certificate was found.
List certificates for a account.
OptionalcertificateHash: undefinedOptionaloptions: UserClientOptionsThe options to use for the request
The found certificates for the account
Get the certificates for the account. If a certificate hash is provided, then only that certificate will be returned, otherwise all certificates for the account will be returned.
OptionalcertificateHash: string | CertificateHashThe hash of the certificate to get, or a CertificateHash instance. If not provided, all certificates for the account will be returned.
Optionaloptions: UserClientOptionsThe options to use for the request
The certificate or certificates for the account, depending on whether a hash was provided.
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.
Optionalquery: { 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
OptionalbaseNetworkInfo?: Partial<OptionalbaseTokenInfo?: BaseTokenInfoOptionaldelegateTo?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>The representative account to delegate the supply to
OptionalvoteSerial?: 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
Add a certificate for a account
The method to use for modifying the certificate: ADD for this signature
The certificate to modify, this should be a Certificate instance.
The certificate bundle containing the intermediate certificates, or null if there are no intermediates.
Optionaloptions: UserClientOptionsThe options to use for the request
The vote staple that was generated and whether it was able to be published
Remove a certificate from a account
The method to use for modifying the certificate, either ADD or REMOVE
The certificate to remove, this should be a Certificate or a CertificateHash instance.
Optionalintermediates: undefinedBecause the SUBTRACT method is used to remove a certificate, intermediates are not needed and should not be defined.
Optionaloptions: UserClientOptionsThe options to use for the request
The vote staple that was generated and whether it was able to be published
Add or remove a certificate for a account
The method to use for modifying the certificate, either ADD or REMOVE
The certificate to modify, this should be a Certificate instance.
Optionalintermediates: null | CertificateBundleThe certificate bundle containing the intermediate certificates, or null if there are no intermediates.
Optionaloptions: UserClientOptionsThe options to use for the request
The vote staple that was generated and whether it was able to be published
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
OptionallistenerOptions: UserClientListenerOptions[EventName]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
options for publishing PublishOptions
The vote staple that was generated and whether it was able to be published
Recover any unpublished or half-publish account artifacts
Optionalpublish: 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
Optionalexternal: stringThe external identifier to use for the transaction
The options to use for the request
The number of times the request has been retried
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
Sync any partially-published account artifacts
Optionalpublish: booleanPublish the recovered staple to the network (default: true)
User client options (common options)
Transmit a set of blocks to the network. This will request short votes and permanent votes for the blocks and then publish them to the network. Optionally it will generate a fee block from a user provided function if fees are required.
The blocks to transmit
User provided options PublishOptions
The result of the publish operation
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
Optionaltarget: string | GenericAccountThe account to set the permissions for, if applicable for this permission
Optionalmethod: 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
StaticacceptFinalize a swap request
AcceptSwapRequest initial swap request block and optional expected token and amounts
User Client Options or optional builder to add the new block too
Optionaloptions: UserClientOptionsSwap Blocks
Finalize a swap request
AcceptSwapRequest initial swap request block and optional expected token and amounts
User Client Options or optional builder to add the new block too
Swap Blocks
StaticcreateInitiate a swap request
CreateSwapRequest Defines what is being sent from Account, TokenAddress and Amount Defines what is being received from Account, TokenAddress and Converted Amount
either a UserClient instance or network and signer from which to create a UserClient
Optionaloptions: UserClientOptionsUser client options (common options)
Swap Block
StaticfilterHelper 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
StaticfromConstruct 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
Optionaloptions: UserClientOptionsThe options to use for this instance of the UserClient class
Optionalaccount?: 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.
OptionalgenerateFeeBlock?: (staple: VoteStaple, options?: UserClientOptions) => Promise<Block>Client provided function to compute the fee block associated with any transactions
OptionalpublishAidURL?: stringIf using the publish aid (see ['usePublishAid']) the URL to use.
The default depends on the network configuration.
OptionalusePublishAid?: 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
StaticfromCreate 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.
Optionaloptions: UserClientOptionsStaticgetA 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
Optionaloptions: 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