UserError
Optional
appOptional
serialiezdOptional
serializedOptional
transactionOptional
verifierOptional
appOptional
approvedOptional
recentOptional
recentPrivate
Optional
seedOptional
transactionAdds Unspent Transaction Outputs (UTXOs) to the user.
This method approves a transaction that is waiting to be executed.
UserError:
A promise that resolves when the approval is completed.
This method compiles and proves a transaction.
UserError:
Optional
appParams: anyOptional parameters for a general application.
A promise that resolves to the compiled and proven transaction.
This method asynchronously creates transaction parameters for a shield operation.
UserError:
The configuration object for the operation.
Optional
appOptional configuration object for app-specific UTXO.
Optional
mergeOptional flag to indicate whether to merge existing UTXOs. Default is true.
Optional
message?: BufferOptional message to include in the transaction.
Optional
minimumOptional, if set, will add minimum SOL to the shielded amount. Default is true.
Optional
publicThe amount of SOL to add to the shielded amount.
Optional
publicThe amount of tokens to shield.
Optional
recipient?: AccountOptional recipient account. If not set, will shield to self.
Optional
senderOptional token account to shield from, else derives ATA.
Optional
skipOptional flag to skip decimal conversions for public amounts. Default is false.
The type of the token to shield ("SOL", "USDC", "USDT").
Optional
utxo?: UtxoOptional UTXO to include in the transaction.
Optional
verifierOptional, the Interface Description Language (IDL) for the verifier.
A promise that resolves to the transaction parameters for the shield operation.
This method is used to create the transaction parameters for storing application UTXO.
UserError:
Optional
amountOptional
amountOptional
appOptional
appOptional
minimumOptional
recipientOptional
senderOptional
skipOptional
stringOptional
token?: stringPromise which resolves to the created transaction parameters.
This method prepares the transaction parameters for a shielded transfer operation .i.e transfer method.
getTxParams
method of TransactionParameters
.Object containing parameters for the transfer operation.
Optional
addWhether to add in UTXOs to the transaction.
Optional
addOptional
amountThe amount of SOL tokens to transfer.
Optional
amountThe amount of SPL tokens to transfer.
Optional
appConfiguration for the application UTXO.
Optional
inOptional
message?: BufferBuffer containing a message to be included in the transaction.
Optional
outOptional
recipient?: AccountThe recipient of the transfer.
Optional
skipWhether to skip decimal conversions.
Optional
token?: stringThe token to be transferred.
Optional
verifierAn Interface Definition Language (IDL) for the verifier.
This method prepares transaction parameters for an unshield operation. This involves:
TransactionParameters.getTxParams
to get the final transaction parameters.Object containing parameters for the unshield operation.
Optional
minimumOptional flag to indicate whether to use minimum lamports or not.
Optional
publicThe amount of SOL to unshield.
Optional
publicThe amount of SPL to unshield.
Optional
recipientRecipient of the SOL token. Defaults to AUTHORITY.
Optional
recipientRecipient of the SPL token. Defaults to AUTHORITY.
The token to be unshielded.
Returns an array of all UTXOs (unspent transaction outputs) across all tokens in the balance.
An array of Utxo objects.
This method retrieves the current balance of the user's account.
If the latest
parameter is set to true (which is the default), it will sync the state of the balance before returning it.
This function checks if the necessary components such as account, provider, Poseidon hasher, Merkle Tree, and Lookup Table are initialized. If any of these components are not initialized, an error will be thrown.
UserError:
A flag to indicate whether to sync the state of the balance before returning it. Defaults to true
.
A promise that resolves to the current balance of the user's account.
Optional
aes?: booleanOptional
asOptional
latestOptional
latestThis method retrieves the transaction history of the user.
Optional
latest: boolean = trueOptional parameter indicating whether to get the latest balance. Defaults to true.
This method retrieves all the non-accepted UTXOs that are not part of the main balance.
If the latest
parameter is set to true (which is the default), it will sync the state of the inbox balance before returning it.
A flag to indicate whether to sync the state of the inbox balance before returning it. Defaults to true
.
A promise that resolves to the inbox balance containing all non-accepted UTXOs.
Retrieves the status of the Unspent Transaction Output (UTXO).
Merges all UTXOs (Unspent Transaction Outputs) for a specific asset.
The public key of the asset whose UTXOs are to be merged.
Optional
latest: boolean = trueOptional parameter indicating whether to get the latest UTXO inbox and balance. Defaults to true.
Performs a shielded transfer to self, merging UTXOs in the process.
An array of commitment strings for merging.
The public key of the asset whose UTXOs are to be merged.
Optional
latest: boolean = falseOptional parameter indicating whether to get the latest UTXO inbox and balance. Defaults to false.
This method sends a transaction that has been compiled and approved, and waits for confirmation of the transaction.
This method is primarily used to execute a shield transaction involving SPL tokens.
UserError:
A promise that resolves to the transaction hash when the transaction is confirmed.
This method processes a shield operation.
This method performs a shield operation, which involves:
Object containing parameters for the shield operation.
Optional
appOptional application UTXO configuration.
Optional
minimumOptional flag to indicate whether to use minimum lamports or not.
Optional
publicOptional extra SOL amount to add to the shielded amount.
Optional
publicThe amount to shield, e.g., 1 SOL = 1, 2 USDC = 2.
Optional
recipient?: stringOptional recipient account. If not set, the operation will shield to self.
Optional
senderOptional sender's token account. If set, this account will be used to shield from, else derives an ATA.
Optional
skipOptional flag to skip decimal conversions.
The token to be shielded, e.g., "SOL", "USDC", "USDT".
This method is used to store the application UTXO.
Optional
amountOptional
amountOptional
appOptional
appOptional
minimumOptional
recipientOptional
senderOptional
skipOptional
stringOptional
token?: stringPromise which resolves to the response of the transaction with the created parameters.
Stores a data message as a UTXO (unspent transaction output) in the user's account.
shield
flag is set to true, it creates a shield transaction parameter using the data message.shield
flag is set to false, it attempts to find a UTXO with a non-zero SOL balance and creates a transfer transaction parameter using the data message.UserError
A Buffer object containing the data to be stored.
A boolean flag indicating whether to use the shield action for storing the data.
The result of the transaction.
This method updates the balance state by identifying spent UTXOs and decrypting new UTXOs.
UserError: When the provider is undefined or not initialized.
A flag to indicate whether AES encryption is used. Defaults to true
.
The balance to be updated. It can be either a Balance
or an InboxBalance
.
The public key of the Merkle Tree PDA.
A promise that resolves to the updated balance. It can be either a Balance
or an InboxBalance
.
This method is used to sync the storage of the user account.
The Interface Description Language (IDL) for the program.
A flag indicating whether to use AES for decryption. Default is true.
Optional
merkleTree: PublicKeyThe public key of the Merkle tree.
A promise which resolves to the balances of the programs after synchronization.
This method performs a transaction using the provided transaction parameters.
Object containing the transaction parameters.
Optional
appAdditional parameters for the application.
The parameters for the transaction.
This method is intended to perform a transaction using the provided input and output UTXOs and the specified action.
Currently, this method is not implemented and will throw an error if called.
Object containing the transaction parameters.
The type of action being performed by this transaction (e.g., TRANSFER, SHIELD, UNSHIELD).
The commitments of the input UTXOs.
The UTXOs that are being spent in this transaction.
The UTXOs that are being created by this transaction.
This method initiates a shielded transfer operation.
createTransferTransactionParameters
method.transactWithParameters
with the obtained parameters.Object containing parameters for the transfer operation.
Optional
amountThe amount of SOL tokens to transfer.
Optional
amountThe amount of SPL tokens to transfer.
Optional
appConfiguration for the application UTXO.
The recipient of the transfer.
The token to be transferred.
This method processes an unshield operation.
This method performs an unshield operation, which involves:
Object containing parameters for the unshield operation.
Optional
minimumOptional flag to indicate whether to use minimum lamports or not.
Optional
publicThe amount of SOL to unshield.
Optional
publicThe amount of SPL to unshield.
Optional
recipientRecipient of the SOL token. Defaults to AUTHORITY.
Optional
recipientRecipient of the SPL token. Defaults to AUTHORITY.
The token to be unshielded.
This method updates the Merkle tree. After updating, it resets the recent transaction parameters and approval status.
This method is primarily used to update the state of the Merkle tree after a transaction. It uses the provider's relayer to update the Merkle tree and resets the transaction-related state.
A promise that resolves when the Merkle tree update request to the relayer is complete.
Static
initThis method asynchronously initializes a User instance.
UserError:
Object containing the initialization parameters.
Optional
account?: AccountOptional account to be used.
Optional
appOptional application UTXO configuration.
The Light provider to be used.
Optional
seed?: stringOptional user seed to instantiate from. If the seed is supplied, it skips the log-in signature prompt.
Optional
utxos?: Utxo[]Optional user UTXOs (Unspent Transaction Outputs) to instantiate from.
Generated using TypeDoc
This class represents a user in the system. It includes properties and methods that allow users to: