Use your zkApp privately

"Cook a Recipe" anonymously with RAILGUN Quickstart
Given a full Recipe and its inputs, RAILGUN Wallet SDK will generate a zero-knowledge proof and a final serialized transaction for the RAILGUN Relay Adapt contract.
This final transaction can be submitted to the blockchain by any wallet, including a Relayer.
cook-recipe-example.ts
const swap = new ZeroXSwapRecipe(sellERC20Info, buyERC20Info, slippagePercentage);
// Inputs that will be unshielded from private balance.
const unshieldERC20Amounts = [{ ...sellERC20Info, amount }];
const recipeInput = { networkName, unshieldERC20Amounts };
const { crossContractCalls, erc20Amounts } = await swap.getRecipeOutput(recipeInput);
// Outputs to re-shield after the Recipe multicall.
const shieldERC20Addresses = erc20Amounts.map(({tokenAddress}) => tokenAddress);
// RAILGUN Quickstart will generate a [unshield -> call -> re-shield]
// transaction enclosing the Recipe multicall.
const {gasEstimate} = await gasEstimateForUnprovenCrossContractCalls(
...
unshieldERC20Amounts,
...
shieldERC20Addresses,
...
crossContractCalls,
...
)
await generateCrossContractCallsProof(
...
unshieldERC20Amounts,
...
shieldERC20Addresses,
...
crossContractCalls,
...
)
const {transaction} = await populateProvedCrossContractCalls(
...
unshieldERC20Amounts,
...
shieldERC20Addresses,
...
crossContractCalls,
...
);
// Submit transaction to RPC.
await wallet.sendTransaction(transaction);
// Note: use @railgun-community/waku-relayer-client to submit
// through a Relayer instead of signing with your own wallet.