Skip to main content

deposit()

deposit() is a function from privacycash/utils used to deposit SOL into the PrivacyCash protocol.

Parameters

The deposit() function takes a single configuration object with the following properties:
ParameterTypeDescription
lightWasmanyThe Poseidon hasher instance (usually from @lightprotocol/hasher.rs).
connectionConnectionSolana web3 connection object.
amount_in_lamportsnumberThe amount of SOL to deposit, specified in lamports.
keyBasePathstringThe base path for loading circuit zkeys (e.g., '/circuit2').
publicKeyPublicKeyThe user’s Solana public key.
transactionSignerFunctionA callback function to sign the generated transaction: (tx: VersionedTransaction) => Promise<VersionedTransaction>.
storageStorageA storage object that implements the Web Storage API (e.g., localStorage).
encryptionServiceEncryptionServiceAn instance of the EncryptionService used for encrypting UTXO data.
referrerstring(Optional) The Solana address of the referrer.

Example Usage

import { depositSPL } from "privacycash/utils"
import { PublicKey } from "@solana/web3.js"

const result = await depositSPL({
    mintAddress: new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), // USDC
    base_units: 1_000_000, // 1 USDC (assuming 6 decimals)
    lightWasm: hasher,
    connection,
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    transactionSigner: async (tx: VersionedTransaction) => {
        return await signTransaction(tx)
    },
    storage: localStorage,
    encryptionService,
    referrer: ''
});

depositSPL()

depositSPL() is used to deposit SPL tokens (like USDC) into the PrivacyCash protocol.

Parameters

The depositSPL() function takes a configuration object with the following properties:
ParameterTypeDescription
mintAddressPublicKeyThe mint address of the SPL token to deposit.
base_unitsnumberThe amount of tokens to deposit, specified in base units (e.g., amount * 10^decimals).
lightWasmanyThe Poseidon hasher instance.
connectionConnectionSolana web3 connection object.
keyBasePathstringThe base path for loading circuit zkeys (e.g., '/circuit2').
publicKeyPublicKeyThe user’s Solana public key.
transactionSignerFunctionA callback function to sign the generated transaction.
storageStorageA storage object (e.g., localStorage).
encryptionServiceEncryptionServiceAn instance of the EncryptionService.
referrerstring(Optional) The Solana address of the referrer.

Example Usage

import { deposit } from "privacycash/utils"

const result = await deposit({
    lightWasm: hasher,
    connection,
    amount_in_lamports: 1_000_000_000, // 1 SOL
    keyBasePath: '/circuit2',
    publicKey: userPublicKey,
    transactionSigner: async (tx: VersionedTransaction) => {
        // let user sign the tx
        return await signTransaction(tx)
    },
    storage: localStorage,
    encryptionService,
    referrer: '' // optional
});