Skip to main content

Quick Start


If you are already familiar with RenVM, RenJS or Web3 libraries, you may be able to jump into using RenJS by reading through the following example and then referring to the sections in the sidebar as required.

If you need more of an introduction to RenVM and RenJS, continue on to Introduction.

To install:

yarn add @renproject/ren @renproject/chains

Swap tabs to change between an example of moving BTC from Bitcoin to Ethereum, and an example of bridging DAI from Ethereum to Binance Smart Chain:

import { providers, Wallet } from "ethers";

import { Bitcoin, Ethereum } from "@renproject/chains";
import RenJS from "@renproject/ren";

// Test account - do not send real funds.
const mnemonic =
"black magic humor turtle symptom liar salmon rally hurt concert tower run";
const network = "testnet";

const main = async () => {
// Initialize Bitcoin and Ethereum.
const bitcoin = new Bitcoin({ network });
const ethereum = new Ethereum({
provider: new providers.JsonRpcProvider(
signer: Wallet.fromMnemonic(mnemonic),

// Create RenJS instance. NOTE - chains must now be linked to RenJS using
// `withChains`.
const renJS = new RenJS(network).withChains(bitcoin, ethereum);

// Create gateway - mints and burns are both initialized with `gateway`.
// Gateway parameters are serializable.
const gateway = await renJS.gateway({
asset: bitcoin.assets.BTC, // "BTC"
from: bitcoin.GatewayAddress(),
to: ethereum.Account(),

// `gateway.fees` exposes values and helpers for calculating fees.

console.log(`Deposit ${gateway.params.asset} to ${gateway.gatewayAddress}`);

// NOTE: Event has been renamed from "deposit" to "transaction".
gateway.on("transaction", (tx) => {
(async () => {
// GatewayTransaction parameters are serializable. To re-create
// the transaction, call `renJS.gatewayTransaction`.

// Wait for remaining confirmations for input transaction.

// RenVM transaction also follows the submit/wait pattern.
await tx.renVM.submit().on("progress", console.log);
await tx.renVM.wait();

// `submit` accepts a `txConfig` parameter for overriding
// transaction config.
await tx.out.submit({
txConfig: {
gasLimit: 1000000,
await tx.out.wait();

// All transactions return a `ChainTransaction` object in the
// progress, with a `txid` field (base64) and a `txidFormatted`
// field (chain-dependent).
const outTx = tx.out.progress.transaction;
console.log("Done:", outTx.txidFormatted);

// All chain classes expose a common set of helper functions (see
// `Chain` class.)

main().catch((error) => {