How to use the ethers.ethers.getDefaultProvider function in ethers

To help you get started, we’ve selected a few ethers 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 / request-client.js / src / api / payment-network / erc20 / address-based-info-retriever.ts View on Github external
public async getTransferEvents(): Promise {
    // Creates a local or default provider
    const provider =
      this.network === 'private'
        ? new ethers.providers.JsonRpcProvider()
        : ethers.getDefaultProvider(this.network);

    // Setup the ERC20 contract interface
    const contract = new ethers.Contract(
      this.tokenContractAddress,
      erc20BalanceOfAbiFragment,
      provider,
    );

    // Create a filter to find all the Transfer logs for the toAddress
    const filter = contract.filters.Transfer(null, this.toAddress) as ethers.providers.Filter;
    filter.fromBlock = 0;
    filter.toBlock = 'latest';

    // Get the event logs
    const logs = await provider.getLogs(filter);
github wslyvh / ctor / server / src / data / EtherscanContractService.ts View on Github external
constructor() {
		this.provider = ethers.getDefaultProvider();
		this.client = new EtherscanClient();
	}
github ChainSafe / lodestar / packages / lodestar / src / eth1 / wallet.ts View on Github external
public constructor(
    privateKey: string,
    contractAbi: string|ParamType[],
    config: IBeaconConfig,
    logger: ILogger,
    provider?: Provider
  ) {
    this.config = config;
    this.logger = logger;
    if(!provider) {
      provider = ethers.getDefaultProvider();
    }
    this.wallet = new Wallet(privateKey, provider);
    this.contractAbi = contractAbi;
  }
github ConnextProject / indra / modules / node / src / swapRate / swapRate.service.ts View on Github external
constructor(
    private readonly config: ConfigService,
    @Inject(MessagingClientProviderId) private readonly messagingClient: ClientProxy,
  ) {
    const provider = ethers.getDefaultProvider();
    this.medianizer = new ethers.Contract(MEDIANIZER_ADDRESS, medianizerAbi, provider);
  }