Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@railgun-community/cookbook

Package Overview
Dependencies
Maintainers
4
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@railgun-community/cookbook

Write a recipe in minutes to convert your dApp to a zkApp.

  • 1.0.8
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-89.71%
Maintainers
4
Weekly downloads
 
Created
Source

Unit Tests Actions Status Integration Tests Actions Status

RAILGUN Cookbook

Write a recipe in minutes to convert your dApp to a zkApp.

Get the Recipe Builder

yarn add @railgun-community/cookbook

Bake a Recipe and call it with RAILGUN Quickstart

// Set up initial parameters.
const sellToken = {tokenAddress: 'DAI'};
const buyToken = {tokenAddress: 'WETH'};
const slippagePercentage = 0.01;

// Use RAILGUN Cookbook to generate auto-validated multi-call transactions from a recipe.
const swap = new ZeroXSwapRecipe(sellToken, buyToken, slippagePercentage);

// Pass inputs that will be unshielded from private balance.
const amount = BigNumber.from(10).pow(18).mul(3000); // 3000 DAI
const unshieldERC20Amounts = [{ tokenAddress: 'DAI', amount }];
const recipeInput = {networkName, unshieldERC20Amounts};
const {populatedTransactions, shieldERC20Addresses} = await swap.getRecipeOutput(recipeInput);

// Use RAILGUN Quickstart to generate a private [unshield -> call -> re-shield] enclosing the recipe.
const crossContractCallsSerialized = populatedTransactions.map(
    serializeUnsignedTransaction,
)
const {gasEstimateString} = await gasEstimateForUnprovenCrossContractCalls(
    ...
    crossContractCallsSerialized,
    ...
)
const {error} = await generateCrossContractCallsProof(
    ...
    crossContractCallsSerialized,
    ...
)
const {serializedTransaction} = await populateProvedCrossContractCalls(
    ...
    crossContractCallsSerialized,
    ...
);

// Submit transaction to RPC.
// Note: use @railgun-community/waku-relayer-client to submit through Relayer.
const transaction = deserializeTransaction(serializedTransaction);
await wallet.sendTransaction(transaction);

Write your own Custom Recipe and Steps

TODO

Testing

Run unit tests

yarn test to run tests without Ganache Fork.

Run integration tests (beta)

yarn test-fork to run all tests, including Ganache Fork tests.

These tests are currently in beta - there are a number of minor issues with test setup scripts. Note that the Ganache fork and setup scripts take about 40 sec to complete.

If you see one of the following error messages during the setup scripts, please run the test suite again:

  1. "socket hang up"
  2. "Error: cannot estimate gas; ..."
  3. "Error: RPC connection error."

FAQs

Package last updated on 04 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc