How to use @ethersproject/providers - 10 common examples

To help you get started, we’ve selected a few @ethersproject/providers 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 ethereum-optimism / optimism / packages / batch-submitter / src / exec / run-batch-submitter.ts View on Github external
}

  for (const [key, val] of Object.entries(requiredEnvVars)) {
    if (val === null || val === undefined) {
      logger.warn('Missing environment variable', {
        key,
        value: val,
      })
      exit(1)
    }
  }

  const clearPendingTxs = requiredEnvVars.CLEAR_PENDING_TXS

  const l2Provider = injectL2Context(
    new JsonRpcProvider(requiredEnvVars.L2_NODE_WEB3_URL)
  )

  const sequencerSigner: Signer = await getSequencerSigner()
  let proposerSigner: Signer = await getProposerSigner()

  const sequencerAddress = await sequencerSigner.getAddress()
  const proposerAddress = await proposerSigner.getAddress()
  // If the sequencer & proposer are the same, use a single wallet
  if (sequencerAddress === proposerAddress) {
    proposerSigner = sequencerSigner
  }

  logger.info('Configured batch submitter addresses', {
    sequencerAddress,
    proposerAddress,
    addressManagerAddress: requiredEnvVars.ADDRESS_MANAGER_ADDRESS,
github ethers-io / ethers.js / packages / ethers / lib / ethers.js View on Github external
exports.Contract = contracts_1.Contract;
exports.ContractFactory = contracts_1.ContractFactory;
var bignumber_1 = require("@ethersproject/bignumber");
exports.BigNumber = bignumber_1.BigNumber;
exports.FixedNumber = bignumber_1.FixedNumber;
var abstract_signer_1 = require("@ethersproject/abstract-signer");
exports.Signer = abstract_signer_1.Signer;
exports.VoidSigner = abstract_signer_1.VoidSigner;
var wallet_1 = require("@ethersproject/wallet");
exports.Wallet = wallet_1.Wallet;
var constants = __importStar(require("@ethersproject/constants"));
exports.constants = constants;
var providers = __importStar(require("@ethersproject/providers"));
exports.providers = providers;
var providers_1 = require("@ethersproject/providers");
exports.getDefaultProvider = providers_1.getDefaultProvider;
var wordlists_1 = require("@ethersproject/wordlists");
exports.Wordlist = wordlists_1.Wordlist;
exports.wordlists = wordlists_1.wordlists;
var utils = __importStar(require("./utils"));
exports.utils = utils;
var logger_1 = require("@ethersproject/logger");
var errors = logger_1.Logger.errors;
exports.errors = errors;
////////////////////////
// Compile-Time Constants
// This is generated by "npm run dist"
var _version_1 = require("./_version");
exports.version = _version_1.version;
var logger = new logger_1.Logger(_version_1.version);
exports.logger = logger;
github ethereum-optimism / optimism / packages / data-transport-layer / src / services / server / service.ts View on Github external
protected async _init(): Promise {
    if (!this.options.db.isOpen()) {
      await this.options.db.open()
    }

    this.state.db = new TransportDB(this.options.db)
    this.state.l1RpcProvider =
      typeof this.options.l1RpcProvider === 'string'
        ? new JsonRpcProvider(this.options.l1RpcProvider)
        : this.options.l1RpcProvider

    this._initializeApp()
  }
github ethereum-optimism / optimism / packages / data-transport-layer / src / services / l2-ingestion / service.ts View on Github external
protected async _init(): Promise {
    if (this.options.legacySequencerCompatibility) {
      this.logger.info(
        'Using legacy sync, this will be quite a bit slower than normal'
      )
    }

    this.state.db = new TransportDB(this.options.db)

    this.state.l2RpcProvider =
      typeof this.options.l2RpcProvider === 'string'
        ? new JsonRpcProvider(this.options.l2RpcProvider)
        : this.options.l2RpcProvider
  }
github ethereum-optimism / optimism / packages / data-transport-layer / src / services / l1-ingestion / service.ts View on Github external
protected async _init(): Promise {
    this.state.db = new TransportDB(this.options.db)

    this.state.l1RpcProvider =
      typeof this.options.l1RpcProvider === 'string'
        ? new JsonRpcProvider(this.options.l1RpcProvider)
        : this.options.l1RpcProvider

    this.logger.info('Using AddressManager', {
      addressManager: this.options.addressManager,
    })

    const Lib_AddressManager = loadContract(
      'Lib_AddressManager',
      this.options.addressManager,
      this.state.l1RpcProvider
    )

    const code = await this.state.l1RpcProvider.getCode(
      Lib_AddressManager.address
    )
    if (fromHexString(code).length === 0) {
github Mrtenz / FindETH / src / components / Main / Main.tsx View on Github external
const initialize = () => {
    const provider =
      window.web3 && window.web3.currentProvider
        ? new Web3Provider(window.web3.currentProvider)
        : new FallbackProvider([
            new JsonRpcProvider('https://api.mycryptoapi.com/eth'),
            new InfuraProvider(),
            new EtherscanProvider()
          ]);

    handleConnect(provider);
  };
github ethereum-optimism / optimism / packages / batch-submitter / src / exec / run-batch-submitter.ts View on Github external
const getSequencerSigner = async (): Promise => {
    const l1Provider = new JsonRpcProvider(requiredEnvVars.L1_NODE_WEB3_URL)

    if (useHardhat) {
      if (!DEBUG_IMPERSONATE_SEQUENCER_ADDRESS) {
        throw new Error('Must pass DEBUG_IMPERSONATE_SEQUENCER_ADDRESS')
      }
      await l1Provider.send('hardhat_impersonateAccount', [
        DEBUG_IMPERSONATE_SEQUENCER_ADDRESS,
      ])
      return l1Provider.getSigner(DEBUG_IMPERSONATE_SEQUENCER_ADDRESS)
    }

    if (SEQUENCER_PRIVATE_KEY) {
      return new Wallet(SEQUENCER_PRIVATE_KEY, l1Provider)
    } else if (SEQUENCER_MNEMONIC) {
      return Wallet.fromMnemonic(SEQUENCER_MNEMONIC, SEQUENCER_HD_PATH).connect(
        l1Provider
github Mrtenz / FindETH / src / components / Main / Main.tsx View on Github external
const initialize = () => {
    const provider =
      window.web3 && window.web3.currentProvider
        ? new Web3Provider(window.web3.currentProvider)
        : new FallbackProvider([
            new JsonRpcProvider('https://api.mycryptoapi.com/eth'),
            new InfuraProvider(),
            new EtherscanProvider()
          ]);

    handleConnect(provider);
  };
github NoahZinsmeister / web3-react / example / index.tsx View on Github external
function getLibrary(provider: any): Web3Provider {
  const library = new Web3Provider(provider)
  library.pollingInterval = 8000
  return library
}
github Mrtenz / FindETH / src / components / Main / Main.tsx View on Github external
const initialize = () => {
    const provider =
      window.web3 && window.web3.currentProvider
        ? new Web3Provider(window.web3.currentProvider)
        : new FallbackProvider([
            new JsonRpcProvider('https://api.mycryptoapi.com/eth'),
            new InfuraProvider(),
            new EtherscanProvider()
          ]);

    handleConnect(provider);
  };

@ethersproject/providers

Ethereum Providers for ethers.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis