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.tsimport { 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 storeconstinitializeEngine=async ():Promise<void> => {// Name for your wallet implementation.// Encrypted and viewable in private transaction history.// Maximum of 16 characters, lowercase.constwalletSource='quickstart demo';// LevelDOWN compatible database for storing encrypted wallets.constdbPath='engine.db';constdb=newLevelDB(dbPath);// Whether to forward Engine debug logs to Logger.constshouldDebug=true;// Persistent store for downloading large artifact files required by Engine.constartifactStore=createArtifactStore('local/dir');// Whether to download native C++ or web-assembly artifacts.// True for mobile. False for nodejs and browser.constuseNativeArtifacts=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.constskipMerkletreeScans=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).constpoiNodeURLs= [...];// Add a custom list to check Proof of Innocence against.// Leave blank to use the default list for the aggregator node provided.constcustomPOILists= []// Set to true if you would like to view verbose logs for private balance and TXID scansconstverboseScanLogging=false;awaitstartRailgunEngine( walletSource, db, shouldDebug, artifactStore, useNativeArtifacts, skipMerkletreeScans, poiNodeURLs, customPOILists, verboseScanLogging )}// App launchtry {awaitinitializeEngine();} catch (err) {// Handle err}