An open API service indexing awesome lists of open source software.

https://github.com/renproject/ren-js-demo

Simple UI to demo RenJS
https://github.com/renproject/ren-js-demo

Last synced: about 1 year ago
JSON representation

Simple UI to demo RenJS

Awesome Lists containing this project

README

          

# RenJS v2 Demo

Simple UI to demo RenJS.

RenJS Demo Screenshot

## Running locally

Clone this repository and run:

```sh
# Install dependencies:
yarn

# Start development server:
yarn start
```

## RenJS v2 Example

```ts
import { Bitcoin, Ethereum } from "@renproject/chains";
import RenJS from "@renproject/ren";
import Web3 from "web3";

export const main = async (web3: Web3) => {
const renJS = new RenJS("mainnet", { logLevel: "log" });

const lockAndMint = await renJS.lockAndMint({
asset: "BTC",
from: Bitcoin(),
to: Ethereum(web3.currentProvider).Account({
address: "0x1234...",
}),

nonce: "0x" + "00".repeat(32),
});

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

lockAndMint.on("deposit", async (deposit) => {
await deposit
.confirmed()
.on("confirmation", (confs, target) =>
console.log(`Confirmations: ${confs}/${target}`)
);

await deposit.signed();
await deposit
.mint()
.on("transactionHash", (txHash) =>
console.log(`TxHash: ${txHash}`)
);
});
};
```