1.1.1 • Published 11 months ago

web3-service-module v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Install

npm i web3-service-module --save

Usage

import { Balance, ConfigWeb3, EstimateFee } from 'web3-service-module/dist';

Configuration

        let conf: ConfigWeb3 = {
            ethereum: {
                rpc: '<<ethereum rpc>>',
                network: 'TESTNET',
            },
            solana: {
                rpc: '<< solana rpc>>',
                network: 'TESTNET',
            },
            bitcoin: {
                key: '<< bitcoin blockcypher key/token  , https://www.blockcypher.com/ >>',
                network: 'TESTNET',
            },
        };

            let balance = new Balance(conf);

            let estimate = new EstimateFee({
              ethereum: {
                rpc: '<<ethereum rpc>>',
                network: 'TESTNET',
              },
              bitcoin: {
                rpc: '<<btc rpc>>',
                network: 'TESTNET',
              },
            });

Example

Ethereum erc20 token transfer estimate

await estimate.ethTokenTransfer(
       '0x2f4Db5d075B654510fD8c200504D53EDcc6E94F5', // from address
       '0x2f4Db5d075B654510fD8c200504D53EDcc6E94F5', // to address
       '0.2',// amount
       '0x7f4E5Ff43175fD55eE27201B7E2EB94dd88E0a13', // token contract address
       18, // decimal
     )

Ethereum transfer estimate

   await estimate.ethTransfer()

Bitcoin transfer estimate

await estimate.btcTransfer('fast') // speed of tx

Ethereum balance

        await balance.eth('0xdeb85cf14a17f098e370ceec188B0a30e8BF5B26'); // wallet address

Ethereum token erc20 balance

await balance.ethToken(
    '0x2f4Db5d075B654510fD8c200504D53EDcc6E94F5', // wallet address
    '0x7f4E5Ff43175fD55eE27201B7E2EB94dd88E0a13', // token contract address
    18, // decimal
  );

Bitcoin balance

 await balance.btc('tb1qee7670wauznq20dc4zly2l2myamrp9t6xz3ctk'); // wallet address

Solana token balance

 await balance.solToken(
      'GdMQcy2gKZEdnb2ntJcNUcroiMmE5c65jHtz3E9ASujB', // wallet address
      '24furDRnVGhwrwJcaZYmUknXgk5qxMLb1ccdaoSssdFC', // token contract address
      9, //decimal
      );
1.1.1

11 months ago

1.1.0

11 months ago