ethers.js

repository·main·Indexed 11 days ago

https://github.com/ethers-io/ethers.js

A complete, compact, and simple TypeScript library for interacting with the Ethereum blockchain and similar networks. Version 6.17.0 provides tools for dapps and wallets, including the Contract class for smart contract interaction, ContractFactory for deployment, and utilities for ABI parsing, address validation, and cryptographic hashing. It supports both ESM and CommonJS environments and includes built-in providers for services like Infura and Alchemy.

Tokens
19.3K
Snippets
92
Records
162
Agent score
91%

What's inside ethers.js

  1. Use default providers with ethers.getDefaultProvider()

    main

    Ethers provides built-in support for several third-party services (such as Ankr, QuickNode, Etherscan, INFURA, and Alchemy) via ethers.getDefaultProvider(). This allows you to start developing immediately without providing your own API keys.

    Note: The default keys provided by ethers are shared and intentionally throttled. For production use, higher capacity, faster responses, and archival data, you should sign up for your own API keys from these services.

  2. Generate Angular code scaffolding

    main

    Use the Angular CLI to scaffold new files within the project. You can generate components, directives, pipes, services, classes, guards, interfaces, enums, or modules using the ng generate command.

    # Generate a new component
    ng generate component component-name
    
    # Generate other types
    ng generate directive|pipe|service|class|guard|interface|enum|module
  3. Use ESM modules for import in projects

    main
    The files in the lib.esm directory are intended for use in ECMAScript Module (ESM) projects where you need to use the import syntax. These files are generated automatically during the build process and should not be edited manually.
  4. Install ethers in the browser (ESM)

    main

    For browser-based applications using ES Modules, you can import the bundled library from the ./dist/ folder. Ensure you use <script type="module">.

    <script type="module">
        import { ethers } from "./dist/ethers.min.js";
    </script>