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

conflux-crosschain

v2.0.0

Published

Conflux Crosschain SDK ==== ## Functions ``` // get data payloads for ethereum mint transaction // token: token type, ('eth', 'usdt') // toAddress: conflux target address // amount: Number | String // return type: string function ethMint(token, toAddress

Downloads

32

Readme


id: shuttleflow_backend_sdk title: Conflux Shuttleflow SDK custom_edit_url: https://github.com/Conflux-Dev/conflux-dex-sdk/edit/master/crosschain/README.md keywords:

  • crosschain
  • shuttleflow sdk

Conflux Shuttleflow SDK

Functions

// get ethereum receive wallet address (used for both eth & usdt) of user.
// when user send money to receive wallet, custodian will directly deposit the 
// money to specified defi.
// user_address: conflux address of user
// defi: the address of defi user want deposit to, see getDefiList below
// node_url: url of running crosschain custodian node
async function getUserReceiveWalletEth(user_address, defi, node_url);

// get bitcoin receive wallet address (used for both eth & usdt) of user.
// when user send money to receive wallet, custodian will directly deposit the 
// money to specified defi.
// user_address: conflux address of user
// defi: the address of defi user want deposit to, see getDefiList below
// node_url: url of running crosschain custodian node
async function getUserReceiveWalletBtc(user_address, defi, node_url);

// get user mint/burn operation list.
// data: JSON object
// {
//    address: (String) user conflux address,
//    type: 'mint' or 'burn'
//    defi: defi address
//    from_chain: "btc" | "eth"
//    status: (array of String) subset of {"doing", "finished"},
// }
// skip: the number of leading results to be ignored
// cnt: the maximum number of results to return (maximum 100)
// node_url: url of running crosschain custodian node
async function getUserOperationList(data, skip, cnt, node_url);

// get supported token list.
// return value: array of object:
 {
    reference: string ('btc'/'eth'/ erc20 token address),
    burn_fee: string (withdraw fee),
    mint_fee: string (mint fee),
    wallet_fee: string (receive wallet deployment fee),
    minimal_mint_value: string,
    symbol: string (cToken name),
    decimals: number (token decimals, e.g. btc is 8, eth is 18, usdt is 6),
    sponsor_value: string (amount of cETH sponsored),
    is_admin: bool (is admin token or not),
    ctoken: string (cToken conflux address)
 }
async function getTokenList(node_url);

// get supported defi list.
// return value: array of object: 
{ 
    defi_name: string (defi name),
    defi_addr: string (defi conflux address) 
}
async function getDefiList(node_url);

// get burn fee of specific token. In 18 decimals.
// token: 'eth' / 'btc' / erc20 address
// return value: string, burn fee of corresponding erc777 token
{
    burn_fee: string,
    mint_fee: string,
    wallet_fee: string,
}
async function getTokenBurnFee(token, node_url);

Const parameters for test

crosschain.test_conf = {
  usdt_addr: // usdt address on rinkeby testnet,
  node_url: // custodian node url,
};

Examples

Import crosschain module.

const crosschain = require('crosschain');
const test_conf = crosschain.test_conf;

get receive wallet address of a user:

let receive_wallet = crosschain.getUserReceiveWalletEth(
    '0x6B6C3A1eC5C689C3dd158b1a6E8Bc722373a2BfA', 
    '0x0000000000000000000000000000000000000000',
    test_conf.node_url
);

0xcc3b0e18c91fc1cd665dc9ec4d4f733971e8f556
// send eth to receive_wallet, custodian will mint cETH for users and then transfer them to CRC-L.
// user's cETH will be locked in the address of CRC-L of cETH.

get user operation list:

crosschain.getUserOperationList({
  address: '0x1f04dcc0432b2df7ce604f0ad4736cadf5ed04ea',// for example
  type: 'mint',
  from_chain: 'eth',
  defi: '0x0000000000000000000000000000000000000000',
  status: ['finished', 'doing'],
}, 0, 100, test_conf.node_url).then(console.log);

{ txs:
   [ { token: 'eth',
       type: 'cETH_mint',
       nonce_or_txid:
        '0x19d57ec6f769dd42e75d339ada0a2c6ce94ecb6a0eea99447ba05898cdc4a421',
       amount: '495000000000000000',
       user_addr: '0x1f04dcc0432b2df7ce604f0ad4736cadf5ed04ea',
       defi: '0x0000000000000000000000000000000000000000',
       to_addr: '0x1f04dcc0432b2df7ce604f0ad4736cadf5ed04ea',
       status: 'finished',
       tx_to: null,
       tx_input: null,
       settled_tx:
        '0x6fca35357dcb1f8f0a4bfab4bf09a4386568742dab1b312da3beb8863171dafe' },
     { token: 'eth',
       type: 'cETH_mint',
       nonce_or_txid:
        '0x8f5ff6efaafe224223e87e1291b9684bc07f09293793a903b0ec94ff8f623fde',
       amount: '505000000000000000',
       user_addr: '0x1f04dcc0432b2df7ce604f0ad4736cadf5ed04ea',
       defi: '0x0000000000000000000000000000000000000000',
       to_addr: '0x1f04dcc0432b2df7ce604f0ad4736cadf5ed04ea',
       status: 'finished',
       tx_to: null,
       tx_input: null,
       settled_tx:
        '0x29fe0c47e79934b16ba71d40e3c9c124c4ae7ee03e61336568fd3b9870313872' } ],
  total: 2 }

get mintable status:

crosschain.isMintable(test_conf.node_url).then(console.log);

true

get defi list:

crosschain.getDefiList(test_conf.node_url).then(console.log);

[ { defi_name: 'Conflux Token',
    defi_addr: '0x0000000000000000000000000000000000000000' },
  { defi_name: 'Conflux DEX',
    defi_addr: '0x8595b7822db70040b6bb30e87bd26eeb66576b37' } ]

get token list:

crosschain.getTokenList(test_conf.node_url).then(console.log);

[ { reference: 'eth',
    burn_fee: '5000000000000000',
    mint_fee: '5000000000000000',
    wallet_fee: '5000000000000000',
    minimal_mint_value: '10000000000000000',
    symbol: 'cETH',
    decimals: 18,
    sponsor_value: '5000000000000000000',
    is_admin: true,
    ctoken: '0x83dfad4705a2bcf8b961bf0fdeac2f22738dc74f' },
  { reference: 'btc',
    minimal_mint_value: '100000',
    symbol: 'cBTC',
    decimals: 8,
    sponsor_value: '0',
    ctoken: '0x8a957d0e7b9b607ef71f4505c3f4bc73b65130d5' },
  { reference: '0x54cc2fbf8733c27984503025d5d2537b29af8054',
    burn_fee: '1000000',
    mint_fee: '1000000',
    wallet_fee: '1000000',
    minimal_mint_value: '1000000',
    symbol: 'cUSDT',
    decimals: 6,
    sponsor_value: '10000000000000000000',
    is_admin: true,
    ctoken: '0x8ea4eefd4fcdb6ad659584166f4c8f083133002d' },
  { reference: '0x6b175474e89094c44da98b954eedeac495271d0f',
    burn_fee: '1000000000000000000',
    mint_fee: '1000000000000000000',
    wallet_fee: '1000000000000000000',
    minimal_mint_value: '1000000000000000000',
    symbol: 'cDAI',
    decimals: 18,
    sponsor_value: '1000000000000000000',
    is_admin: true,
    ctoken: '0x8008e2134e001a946fe52e011aef0d01ba834762' },
  { reference: '0xc00e94cb662c3520282e6f5717214004a7f26888',
    burn_fee: '5000000000000000',
    mint_fee: '5000000000000000',
    wallet_fee: '5000000000000000',
    minimal_mint_value: '5000000000000000',
    symbol: 'cCOMP',
    decimals: 18,
    sponsor_value: '1000000000000000000',
    is_admin: false,
    ctoken: '0x80f14a1b69dae80bcbc4bdd2dd381418a92e1e8b' },
  { reference: '0x431ad2ff6a9c365805ebad47ee021148d6f7dbe0',
    burn_fee: '3000000000000000000',
    mint_fee: '3000000000000000000',
    wallet_fee: '3000000000000000000',
    minimal_mint_value: '3000000000000000000',
    symbol: 'cDF',
    decimals: 18,
    sponsor_value: '1000000000000000000',
    is_admin: false,
    ctoken: '0x8c046fbcd70a23e0c34f8dfecda0c582a4fe72b5' },
  { reference: '0xdd974d5c2e2928dea5f71b9825b8b646686bd200',
    burn_fee: '1000000000000000000',
    mint_fee: '1000000000000000000',
    wallet_fee: '1000000000000000000',
    minimal_mint_value: '1000000000000000000',
    symbol: 'cKNC',
    decimals: 18,
    sponsor_value: '1000000000000000000',
    is_admin: false,
    ctoken: '0x8f1624956129064805bb8b239d185f12b5d8aacc' } ]