2.1.1 • Published 1 month ago

@peersyst/xrp-evm-contracts v2.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 month ago

Bridge Contracts implementations Project

This project defines and implements the necessary contracts to run a bridge between 2 chains. It is developed using hardhat.

Prerequisites

Installation and use as npm package

To install the pkg using yarn in your npm package:

yarn add @peersyst/xrp-evm-contracts

To use the pkg contracts definitions we can import them and deploy the pkg or just use them to make requests in the blockchain

import {
    XChainUtilsUnsafe__factory,
    BridgeDoorMultiToken__factory,
    BridgeDoorMultiToken,
    Utils__factory,
} from "@peersyst/xrp-evm-contracts";
import { Wallet, JsonRpcProvider } from "ethers";

export const deployBridge = (signerWallet: Wallet): Promise<void> {
        console.log(`Deploying Utils...`);
        const UtilsFactory = new Utils__factory(signerWallet);
        const Utils = await UtilsFactory.deploy();
        await Utils.deployed();
        console.log(`Utils library smart contract set up at ${Utils.address}`);

        console.log(`Deploying XChainUtils...`);
        const xChainUtilsFactory = new XChainUtilsUnsafe__factory({ ["contracts/Utils.sol:Utils"]: Utils.address }, signerWallet);
        const xChainUtils = await xChainUtilsFactory.deploy();
        await xChainUtils.deployed();
        console.log(`XChainUtils library smart contract set up at ${xChainUtils.address}`);

        console.log(`Deploying BridgeDoorMultiToken...`);
        const bridgeDoorMultiTokenFactory = new BridgeDoorMultiToken__factory(
            { ["contracts/XChainUtils.sol:XChainUtils"]: xChainUtils.address },
            signerWallet,
        );
        const bridgeDoorMultiToken = await bridgeDoorMultiTokenFactory.deploy(safeAddress);
        await bridgeDoorMultiToken.deployed();
        console.log(`Bridge deployed successfully!`);
}

export const getBridge = (address: string): BridgeDoorMultiToken {
    const provider = new JsonRpcProvider(chain.rpcUrl);
    return BridgeDoorMultiToken__factory.connect(address, provider);
}

Use and installation locally

To install and build use the following commands

yarn
yarn build

Testing

To test use the following command:

yarn test

Deploying the libraries

To deploy the libraries use the following command:

yarn hardhat deploy --network <network_name>

Deploying and upgrading the proxy

To deploy the proxy use the following command:

yarn hardhat run --network <network_name> scripts/002-deploy-proxy.ts 

To upgrade the proxy use the following command:

yarn hardhat run --network <network_name> scripts/003-upgrade-proxy.ts 

Other useful commands

These include hardhat and linter commands

yarn hardhat accounts
yarn hardhat compile
yarn hardhat clean
yarn hardhat test
yarn hardhat node
yarn hardhat help
REPORT_GAS=true yarn hardhat test
yarn hardhat coverage
yarn lint
yarn lint:ts
yarn lint:sol
yarn hardhat size-contracts

Documentation

The official documentation can be found here

2.1.1

1 month ago

2.1.0

2 months ago

1.0.2

8 months ago

2.0.0-alpha.3

7 months ago

2.0.0-alpha.4

6 months ago

2.0.0-alpha.5

6 months ago

2.0.0-alpha.0

8 months ago

2.0.0-alpha.1

7 months ago

2.0.0-alpha.2

7 months ago

2.0.0

6 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.3.0

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.0

12 months ago