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

jcc-ethereum-utils

v0.2.7

Published

Toolkit of crossing chain from Ethereum to SWTC chain

Downloads

14

Readme

jcc-ethereum-utils

Toolkit of crossing chain from EVM networks to SWTC chain.

npm Build Status Coverage Status Dependencies npm downloads PRs Welcome

Description

Transfer token automatically from Ethereum to SWTC chain. Support ether and erc20 tokens.

e.g. you transfer 1 eth to Ethereum Fingate from your ethereum address, If success the contract will automatically transfer 1 jeth to your swtc address from Jingtum Fingate in a few minutes.

Support token list of erc20

If you wanna we support other erc20 token, please contact us.

Installtion

npm i jcc-ethereum-utils

CDN

jcc_ethereum_utils as a global variable.

<script src="https://unpkg.com/jcc-ethereum-utils/dist/jcc-ethereum-utils.min.js"></script>

Usage

Breaking changes since 0.1.4, if you used 0.1.3 see this demo.

// demo
import { Fingate, Ethereum, ERC20 } from "jcc-ethereum-utils";

// Ethereum node
const node = "https://eth626892d.jccdex.cn";

// Your ethereum secret
const ethereumSecret = "";

// Your ethereum address
const ethereumAddress = "";

// Your swtc address
const swtcAddress = "";

// Deposit amount
const amount = "1";

// Ethereum fingate contract address, don't change it.
const scAddress = "0x3907acb4c1818adf72d965c08e0a79af16e7ffb8";

try {
  // deposit 1 ETH
  const ethereumInstance = new Ethereum(node);
  ethereumInstance.initWeb3();

  const fingateInstance = new Fingate();
  fingateInstance.init(scAddress, ethereumInstance);

  // Check if has pending order, if has don't call the next deposit api
  const state = await fingateInstance.depositState(ethereumAddress);

  if (fingateInstance.isPending(state)) {
    return;
  }

  // start to transfer 1 ETH to fingate address
  const hash = await fingateInstance.deposit(ethereumSecret, swtcAddress, amount);
  console.log(hash);
} catch (error) {
  console.log(error);
}

// deposit erc20 token

try {
  // deposit 1 JCC

  // JCC contract address
  const jccContractAddress = "0x9BD4810a407812042F938d2f69f673843301cfa6";

  const ethereumInstance = new Ethereum(node);
  ethereumInstance.initWeb3();

  const erc20Instance = new ERC20();
  erc20Instance.init(jccContractAddress, ethereumInstance);

  const fingateInstance = new Fingate();
  fingateInstance.init(scAddress, ethereumInstance);

  fingateInstance.initErc20(erc20Instance);

  // Check if has pending order, if has don't call depositErc20 api
  const state = await fingateInstance.depositState(address, jccContractAddress);

  if (fingateInstance.isPending(state)) {
    return;
  }

  const amount = "1";

  const receipts = await fingateInstance.depositErc20(ethereumSecret, swtcAddress, amount);
  console.log(receipts);
} catch (error) {
  console.log(error);
}

API

see API.md