npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@infinityswapofficial/evm-client

v0.2.8

Published

Bitfinity EVM TS Client

Downloads

146

Readme

Bitfinity Evm-client

Introduction

This plugin demonstrates the process of bridging tokens between an ICRC chain and an EVM chain. The bridge allows tokens to be transferred between these two blockchain environments. The provided test files utilize the Chain class to perform various actions related to token bridging.

Installation

Using NPM

npm install @infinityswapofficial/evm-client

Using Yarn

yarn add @infinityswapofficial/evm-client

Usage

    import { Chain } from "@infinityswapofficial/evm-client";
    const bridge = new Chain({
        minterCanister,
        Ic,
        signer,
        provider,
        rpcUrl, // eg https://testnet.bitfinity.network 
        icHost, // Your icHost url
    });

Find test files at src/tests

Add Operation Points

    const operationReceipt = await bridge.add_operation_points();

Get Bitfinity Bridge Contract Address

Call the get_bft_bridge_contract on the Chain class to get bft bridge contract address

    const bftBridgeContractAddress = await bridge.get_bft_bridge_contract();

Deploy a BFT Wrapped Token

In other to bridge, you must have a wrapped version of your token on bft. If the wrapped token already exists, the function will return the wrapped token and not create another. The function takes 3 parameters. The first being the name of the token, the second the symbol of the token and the last is the token in Id256. Example below.

    import { Chain } from "@infinityswapofficial/evm-client";
    const ercToken = await bridge.deploy_bft_wrapped_token(
        "Token",
        "TKN",
        tokenInId256,
      );

Get Id256 of Token

For ICRC Token

example

import {Id256Factory} from "@infinityswapofficial/evm-client";
tokenInId256 = Id256Factory.fromPrincipal(Principal_of_token)

For EVM Token

example

import {Id256Factory} from "@infinityswapofficial/evm-client";
const chain_id = 355113
tokenInId256 = Id256Factory.fromAddress(new AddressWithChainID(erc20TokenAddress, chain_id))

Burning icrc Tokens

Burns a specified amount of ICRC tokens to initiate the creation of an ERC20 mint order. Operation_id is a unique number to add to your burn. This can be used to retrieve a burn or initialize one in case something goes wrong. You can generate one using bridge.generateOperationId() or use your own format.

const operation_id = bridge.generateOperationId();
const signedMintOrder = await bridge.burn_icrc2_tokens(TOKEN_PRINCIPAL,amount, operation_id);

Mint ERC20 Token

Mints ERC20 tokens on the EVM chain using a previously generated mint order.

const signedMintOrder = await bridge.mintOrder(signedMintOrder);

Get all cached Transations

Retrieves cached transactions, including mint transactions.

const cachedMintTx = await bridge.getCacheTx(); // get burnt transaction hash
const cachedMintTx = await bridge.getCacheTx("evm_client_mint"); // get mint results
const cachedMintTx = await bridge.getCacheTx("evm_client_mint_order"); // get mint order

Burn ERC20 Token

Burn erc20 tokens

const burnTxHash = await bridge.burn_erc_20_tokens(ercToken, 1000000, 0);

Get Operation id from burnt transaction hash

Burn erc20 tokens

const operation_id = await bridge.get_operation_id(Principal.fromText(canisterIds.evm.local),burnTxHash!);

Minting ICRC Tokens after burning erc20 tokens

const mintResult = await bridge.mint_icrc_tokens(operation_id,Principal.fromText(canisterIds.token.local));

Get base token principal from wrapped erc20 token address

const baseTokenPrincipal = await bridge.get_base_token(ercToken.getAddress());