1. Start the RAILGUN Privacy Engine

Please first see Getting Started for installation instructions.

The RAILGUN Engine SDK is a dependency of Wallet SDK. It contains complex scanning technologies, cryptography, transaction wrappers, and contract interfaces. Wallet SDK, in turn, simplifies and abstracts the intricate functionalities provided by this library.

The Engine requires a LevelDOWN compatible database for storing encrypted wallets, like level-js.

yarn add level-js @types/level-js

On app launch, start the Engine:

// main.ts
import { 
  startRailgunEngine, 
} from '@railgun-community/wallet';
import LevelDB from 'level-js';
import { createArtifactStore } from './create-artifact-store'; // We'll get to this in Step 2: Build a persistent store

const initializeEngine = async (): Promise<void> => {
  // Name for your wallet implementation.
  // Encrypted and viewable in private transaction history.
  // Maximum of 16 characters, lowercase.
  const walletSource = 'quickstart demo';
  
  // LevelDOWN compatible database for storing encrypted wallets.
  const dbPath = 'engine.db';
  const db = new LevelDB(dbPath);
  
  // Whether to forward Engine debug logs to Logger.
  const shouldDebug = true;
  
  // Persistent store for downloading large artifact files required by Engine.
  const artifactStore = createArtifactStore('local/dir');
  
  // Whether to download native C++ or web-assembly artifacts.
  // True for mobile. False for nodejs and browser.
  const useNativeArtifacts = false;
  
  // Whether to skip merkletree syncs and private balance scans. 
  // Only set to TRUE in shield-only applications that don't 
  // load private wallets or balances.
  const skipMerkletreeScans = false;
  
  // Array of aggregator node urls for Private Proof of Innocence (Private POI), in order of priority.
  // Only one is required. If multiple urls are provided, requests will fall back to lower priority aggregator nodes if primary request fails.
  // Please reach out in the RAILGUN builders groups for information on the public aggregator nodes run by the community.
  //
  // Private POI is a tool to give cryptographic assurance that funds
  // entering the RAILGUN smart contract are not from a known list
  // of transactions or actors considered undesirable by respective wallet providers.
  // For more information: https://docs.railgun.org/wiki/assurance/private-proofs-of-innocence
  // (additional developer information coming soon).
  const poiNodeURLs = [...];
  
  // Add a custom list to check Proof of Innocence against.
  // Leave blank to use the default list for the aggregator node provided.
  const customPOILists = []
  
  // Set to true if you would like to view verbose logs for private balance and TXID scans
  const verboseScanLogging = false;
  
  await startRailgunEngine(
    walletSource,
    db,
    shouldDebug,
    artifactStore,
    useNativeArtifacts,
    skipMerkletreeScans,
    poiNodeURLs,
    customPOILists,
    verboseScanLogging
  )
}

// App launch
try {
  await initializeEngine();
} catch (err) {
  // Handle err
}

startRailgunEngine will throw on error.

Last updated