multichain-interop-js
TypeScript icon, indicating that this package has built-in type declarations

3.6.1 • Public • Published

MultiChain Interoperability SDK

TypeScript SDK for multi-chain transaction operations, supporting login signatures and transaction submissions for mainstream blockchains such as Ethereum, BSC, Arbitrum, Solana and Tron.

Features

  • 🌐 Multi-chain support: integrated EVM-compatible chains (ETH/BSC/Arbitrum) and non-EVM chains (Solana/Tron)
  • 🔐 Wallet connection: support MetaMask/Phantom/TronLink and other mainstream wallets
  • 📦 Out-of-the-box: encapsulate chain interaction logic to simplify DApp development

Install

npm install multichain-interop-js
# or
yarn add multichain-interop-js

Currenly Supported Chain Types

  • Ethereum
  • BSC
  • Arbitrum
  • Solana
  • Tron

Wallet login example

import MultichainInteropJs, { AccountInfo, ChainType } from 'multichain-interop-js';

// Initialize configuration (update chainApi URL when necessary)
MultichainInteropJs.setConfig({
    chainApi: "https://expnode.amaxscan.io",
    proxyApi: "https://truedex.io/proxy",
    ownerContract:"interopowner",
    defaultDelay: 3000,
});

// Ethereum Login
const ethLogin = async () => {
    try {
        const account: AccountInfo | string = await MultichainInteropJs.loginByChain('eth' as ChainType);
        if(typeof account === 'string'){
            console.log('errorMsg',account)
        }else{
            console.log('successObject',account)
        }
    } catch (error) {
        console.error('Login failed:', error);
    }
};

// Solana Login
const solanaLogin = async () => {
    const account: AccountInfo | string = await MultichainInteropJs.loginByChain('solana' as ChainType);
    if(typeof account === 'string'){
        console.log('errorMsg',account)
    }else{
        console.log('Solana public key',account?.address)
    }
};

Submit transaction example

const sendTransaction = async () => {
    const result = await MultichainInteropJs.transactByChain(
        'eth',                   // Chain Type
        '0x123...4ow',           // User address
        [{                       // Transaction parameters
            contract: 'abc.contract', //update contract accordingly
            action: 'transfer',
            data: {
                from: 'apl...eg',
                to: 'apl...ee',
                quantity: '1.0000 ETH'
            }
        }]
    );

    if (result.includes('success:')) {
        console.log('Transaction confirmed!');
    }else{
        console.log('errorMsg',result)
    }
};

Package Sidebar

Install

npm i multichain-interop-js

Weekly Downloads

41

Version

3.6.1

License

MIT

Unpacked Size

61.6 kB

Total Files

35

Last publish

Collaborators

  • black.pit