Contributing and Hacking

The ethers.js library is something that I've written out of necessity, and has grown somewhat organically over time.

Many things are the way they are for good (at the time, at least) reasons, but I always welcome criticism, and am completely willing to have my mind changed on things.

So, pull requests are always welcome, but please keep a few points in mind:

In general, please start an issue before beginning a pull request, so we can have a public discussion and figure out the best way to address the problem/feature. :)


If you wish to modify the source code, there are a few steps involved in setting up your environment.

Since the library uses a monorepo, you must install an initial required set of libraries, which can then be used to install the remaining libraries used within each package, as well as link all the packages within the repo with each other.

Preparing for builds
# Clone the repository /home/ricmoo> git clone /home/ricmoo> cd ethers.js # Install the base dependencies /home/ricmoo/ethers.js> npm install # Install each module's dependencies and link the libraries # internally, so they reference each other /home/ricmoo/ethers.js> npm run bootstrap

Making your changes

TODO: Add more information here.

Watching and Building
# Begin watching the files and re-building whenever they change /home/ricmoo/ethers.js> npm run auto-build # Sometimes the issue only affects the ESM modules /home/ricmoo/ethers.js> npm run auto-build-esm # Or if you only need to run a single build /home/ricmoo/ethers.js> npm run _build-cjs /home/ricmoo/ethers.js> npm run _build-esm
# Rebuilds all files and bundles testcases up for testing /home/ricmoo/ethers.js> npm test # Often you don't need the full CI experience /home/ricmoo/ethers.js> npm run _test-node
Preparing the Distribution
/home/ricmoo/ethers.js> npm run update-version


The documents are generated using Flatworm documentation generation tool, which was written for the purpose of writing the documentation for ethers.

Style Guide (this section will have much more coming):


To build the documentation, you should first follow the above steps to build the ethers library.

Building the docs will generate several types of output:

Building the Documentations
/home/ricmoo/ethers.js> npm run build-docs


When building the documentation, all code samples are run through a JavaScript VM to ensure there are no typos in the example code, as well the exact output of results are injected into the output, so there is no need to keep the results and code in-sync.

However, this can be a bit of a headache when making many small changes, so to build the documentation faster, you can skip the evaluation step, which will inject the code directly.

Build docs skipping evaluation
/home/ricmoo/ethers.js> npm run build-docs -- --skip-eval

Previewing Changes

To preview the changes locally, you can use any standard web server and run from the /docs/ folder, or use the built-in web server.

The same caveats as normal web development apply, such flushing browser caches after changing (and re-building) the docs.

Running a webserver
/home/ricmoo/ethers.js> npm run serve-docs