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
- Host: GitHub
- URL: https://github.com/renproject/ren-js-demo
- Owner: renproject
- Created: 2020-10-14T09:26:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-26T04:28:34.000Z (about 5 years ago)
- Last Synced: 2023-03-02T04:22:06.019Z (over 3 years ago)
- Language: TypeScript
- Size: 64 MB
- Stars: 4
- Watchers: 9
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RenJS v2 Demo
Simple UI to demo RenJS.

## 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}`)
);
});
};
```