Highlights ethers.js: September 2021

RicMoo
RicMoo
Published in
4 min readSep 8, 2021

--

The current version of ethers as of this article is 5.4.6.

“Drunken Lampposts” in Halifax, N.S.

Heya!

Time flies by too fast, but it’s been a few months, so it’s time for yet another quarterly-ish update on ethers and how I’m enjoying my time working on it.

I appreciate the pressure of GitCoin Grants, which helps force me to keep up with these articles, otherwise it’s too easy to forego practicing natural-language writing in favour of machine-readable “stories” (i.e. code). :)

There have been a few minor bug fixes, documentation updates and some small improvements and there will probably be another minor-bump soon, to accommodate some changes that various L2 solutions are craving.

But the big items to show off are EIP-1559 and the new ethers Playground.

EIP-1559 (a.k.a. London) — Fee Market Hardfork

EIP-1559 is out in the wild and running smoothly. Surprisingly smooth considering the significance of the change, which instills me with a great deal of confidence we can achieve great things together.

Since it was released, I have not had a single transactions not fulfilled within a minute; the prices have got out of hand due to “NFT-mania” a bit, but whenever the price is in the ballpark I can live with, things work without a hiccup in sight.

On that note, full EIP-1559 support was available as of version 5.4.0 and there should have been no code changes needed for most developers.

Providers and Signers automatically detect if a network supports EIP-1559 and use it if available, otherwise fallback onto legacy transactions, unless explicitly told to do otherwise (via an explicit type field).

The Provider does have a new method (i.e. provider.getFeeData()) and few new properties to blocks (block.baseFee), transactions (tx.maxFeePerGas and tx.maxPriorityFeePerGas) and receipts (receipt.effectiveGasPrice) in responses for those who need access to the nitty-gritty.

One further point to consider is if you have code that uses tx.gasPrice, that it can now change depending on whether the block is in the mempool (in which case it is the maxFeePerGas) or has been mined (in which case it is the effectiveGasPrice). The future of what gasPrice will mean is still an ongoing conversation, so just keep that in mind if you find yourself using it.

Also, the transactions serializer and parser recognize type 2 to support EIP-1559, but with the addition of type transactions earlier this year (for accessList transactions), this required very few changes. It took longer to write the script to generate test cases than it did to add it.

The Playground… It’s alive!

The Playground is where I spent a substantial portion of my time over the last few month.

It is something I’ve wanted to put together for a long time, talked about on numerous occasions and something I’ve already got a great deal of use out of; prototyping and tinkering some ideas, as well as help create examples for GitHub issues and discussions.

It is basically a web-based REPL environment with ethers loaded in it, sandboxing eval calls in a WebWorker, and providing a friendly UI and documentation along side the commands you use.

Experimental Features

There are some features which are off by default, as they are still experimental and in some cases may be more trouble than they are worth.

The experimental Auto-Complete uses a custom JavaScript lexer, which parses JavaScript backwards from the cursor to make educated guesses as to what you are trying to do.

It has full access to the help sub-system though, so it can recommend operations which might not otherwise be accessible to the JavaScript runtime and provide placeholders for the required parameters. It will get better with time, but please feel free to complain.

The experimental Pass-Through Provider enables access to MetaMask (or other injected Web3 providers) from the WebWorker environment. Every operation requested through the provider is logged to the screen, so you can see what is going on.

Soon there will be an additional portion of UI providing an extra level of security between the WebWorker environment and MetaMask, allowing the operation to be rejected before even being passed along.

Odds ‘n Ends

  • Polygon (matic) support added to the various third-party providers, like INFURA and Alchemy; once a billing issue is worked out it will be available with the default provider
  • Launched the new ethers.org site; if you have an open-source project built on ethers, please submit it to be included on the site
  • Resolving a lot of stale issues and trying to move issues which only served as discussions to the new GitHub Discussions feature, once this is under control I can start releasing the beta v6 branch
  • More work on the Ancillary Package template, so it is easier to share the work load and get more exciting packages working in tandem with ethers
  • Lots of little things

Until next we meet again…

If you have any comments or suggestions, please reach out to me on Twitter (DMs are open, or just blast me publicly) or on GitHub (e-mail of ethers discussions).

Thanks! And keep on hacking! :)

“This was a triumph; I’m making a note here: HUGE SUCCESS. It’s hard to overstate my satisfaction.”

--

--