withdraw()
withdraw() is a function from privacycash/utils used to withdraw SOL from the PrivacyCash protocol to a specified recipient address.
Parameters
Thewithdraw() function takes a configuration object with the following properties:
| Parameter | Type | Description |
|---|---|---|
amount_in_lamports | number | The amount of SOL to withdraw, specified in lamports. |
connection | Connection | Solana web3 connection object. |
encryptionService | EncryptionService | An instance of the EncryptionService used for decrypting UTXO data. |
keyBasePath | string | The base path for loading circuit zkeys (e.g., '/circuit2'). |
publicKey | PublicKey | The owner’s Solana public key. |
storage | Storage | A storage object that implements the Web Storage API (e.g., localStorage). |
recipient | PublicKey | The Solana address that will receive the withdrawn funds. |
lightWasm | any | The Poseidon hasher instance (usually from @lightprotocol/hasher.rs). |
Example Usage
withdrawSPL()
withdrawSPL() is used to withdraw SPL tokens from the PrivacyCash protocol to a specified recipient address.
Parameters
ThewithdrawSPL() function takes a configuration object with the following properties:
| Parameter | Type | Description |
|---|---|---|
mintAddress | string | The mint address of the SPL token. |
base_units | number | The amount of tokens to withdraw, specified in base units. |
connection | Connection | Solana web3 connection object. |
encryptionService | EncryptionService | An instance of the EncryptionService. |
keyBasePath | string | The base path for loading circuit zkeys. |
publicKey | PublicKey | The owner’s Solana public key. |
storage | Storage | A storage object (e.g., localStorage). |
recipient | PublicKey | The Solana address that will receive the withdrawn funds. |
lightWasm | any | The Poseidon hasher instance. |
