Skip to main content

Gateway Class

Reference

Gateway (TypeDoc)​

renJS.gateway is used to initialize Gateway instances. The parameters are as follows:

interface GatewayParams<
FromPayload extends { chain: string },
ToPayload extends { chain: string }
> {
/* Required */

// The asset being minted or burned - e.g. "BTC".
asset: string;

// The payload provided by the from-chain.
from: FromPayload;

// The payload provided by the to-chain.
to: ToPayload;

/* Optional */

// See section on nonces. A URL-base64 string or a number.
nonce?: string | number;

// Provide a specific RenVM shard - this will come in handy when RenVM shards rotate daily.
shard?: RenVMShard;

// A tag for tracking the volume of a particular bridge (still being implemented)
tag?: string;
}

The from and the to parameters will usually be created using a chain class (e.g. ethereum.Accont() or bitcoin.GatewayAddres()).

After creating the gateway, any missing parameters are filled in and available from gateway.params. If you are persisting the gateway details, then you should save gateway.params instead of the parameters being passed into renJS.gateway. gateway.params can be serialized and deserialized using JSON.stringify and JSON.parse:

// User creates new gateway
let gateway = await renJS.gateway({...});
const paramsToSave: string = JSON.stringify(gateway.params);

// User resumes gateway
gateway = await renJS.gateway(JSON.parse(paramsToSave));

The methods and properties on a Gateway instance are:

Methods

processDeposit - manually pass in a the details of a transaction represented by anInputChainTransaction

on - register listeners for"transaction" events - see eventEmitter below for accessing otherEventEmitter methods


Properties

params - the parameters that can be used to recreate the Gateway

provider - the connected RenVM provider

fromChain - access the from-payload's chain instance that was passed into renJS.withChains

toChain - access the to-payload's chain instance that was passed into renJS.withChains

provider - the same provider as renJS.provider

fees - for calculating the expected fees (see fees)

gatewayAddress - for deposit gateways

inSetup - transactions required before submitting the in transaction

in - for contract gateways, the input transaction submitter or waiter

eventEmitter - the event emitter that gateway.on calls - see eventEmitter.once, eventEmitter.removeListener , eventEmitter.removeAllListeners and eventEmitter.listenerCount