How to use the web3-eth.providers function in web3-eth

To help you get started, we’ve selected a few web3-eth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github RequestNetwork / requestNetwork / packages / ethereum-storage / src / smart-contract-manager.ts View on Github external
} = {
      maxConcurrency: Number.MAX_SAFE_INTEGER,
    },
  ) {
    this.maxConcurrency = maxConcurrency;
    this.logger = logger || new Utils.SimpleLogger();

    this.maxRetries = maxRetries;
    this.retryDelay = retryDelay;

    web3Connection = web3Connection || {};

    try {
      this.eth = new web3Eth(
        web3Connection.web3Provider ||
          new web3Eth.providers.HttpProvider(config.getDefaultEthereumProvider()),
      );
    } catch (error) {
      throw Error(`Can't initialize web3-eth ${error}`);
    }

    // Checks if networkId is defined
    // If not defined we use default value from config
    this.networkName =
      typeof web3Connection.networkId === 'undefined'
        ? config.getDefaultEthereumNetwork()
        : EthereumUtils.getEthereumNetworkNameFromId(web3Connection.networkId);

    // If networkName is undefined, it means the network doesn't exist
    if (typeof this.networkName === 'undefined') {
      throw Error(`The network id ${web3Connection.networkId} doesn't exist`);
    }
github melonproject / protocol / src / utils / scratchpad.ts View on Github external
import * as fs from 'fs';
import * as path from 'path';
import * as Eth from 'web3-eth';

// Websocket could be the problem
// HTTP is faster, but same error
const eth = new Eth(new Eth.providers.HttpProvider('http://localhost:8545'));

const rawABI = fs.readFileSync(
  path.join(process.cwd(), 'out', 'factory', 'FundFactory.abi'),
  { encoding: 'utf-8' },
);
const ABI = JSON.parse(rawABI);
const fundFactoryAddress = '0x801cd3BCa02ffB46Ee5cf43B023Aa3619089d16b';
const contract = new eth.Contract(ABI, fundFactoryAddress);

const args = [
  ['0x9a8D6f20b917eA9542EEE886c78fE41C638A3d45'],
  [],
  ['0x4b1a08B5DBcf3386f22DB1d694beF84d8EF4B340'],
  [
    '0xc0dd7a9D5470216eaf97DD2CEcAc259da1f7Af2E',
    '0x2B83156799AB55F5581263Cd544372B9af2c2Cfe',
github melonproject / protocol / src / utils / environment / constructEnvironment.ts View on Github external
const makeHttpProvider = endpoint =>
  new web3Eth.providers.HttpProvider(endpoint);
github melonproject / protocol / src / utils / environment / constructEnvironment.ts View on Github external
const makeIpcProvider = endpoint => new web3Eth.providers.IpcProvider(endpoint);
github melonproject / protocol / src / utils / environment / constructEnvironment.ts View on Github external
const makeWsProvider = endpoint =>
  new web3Eth.providers.WebsocketProvider(endpoint);

web3-eth

Web3 module to interact with the Ethereum blockchain and smart contracts.

LGPL-3.0
Latest version published 19 days ago

Package Health Score

98 / 100
Full package analysis

Similar packages