TrueFi Engineering
Published in

TrueFi Engineering

Testing contracts that use ENS with ENSBuilder

When it comes to testing contracts and functionality that uses Ethereum Naming System (ENS), it is a bit tricky. It is difficult to test in isolation from ENS, and it is hard to stub ENS.

We stumble upon that challenge when working on Universal Login SDK.

To solve that problem we created a simple library called ENSBuilder, which allows one to quickly set up and configure a standalone instance of ENS, on a local environment, in tests or on a test chain.

With ENSBuilder setup is as easy as a single method call:

const ensAddress = await builder.bootstrapWith(‘example’, ‘eth’);

And you already have a copy of ENS, up and running, as well as two domains registered: ‘ens’ and ‘example.ens’.

You can now register an address:

await builder.registerAddress(‘marek’, ‘example.eth’, ‘0x…’);


The builder uses ethers.js as a contract abstraction. Web3js is also supported but will require you to pass a private key. We plan to add better web3js support if we see requests from people to do it. We would also happily accept PRs :)

Why Ethers.js you may ask?
We find ethers.js to be a stable, light, feature complete and production ready alternative to web3js. Therefore we are using it both for tests as well as application code.

Getting Started

For in-depth information as well as a quick tutorial go to EnsBuilder GitHub.

If you enjoyed this post, please hit the 👏 button and if you would like to get notified when new story shows up, click follow button below.

You can also follow us on Facebook and Twitter.



Team working on TrueFi talks about OSS (useDApp and Waffle), good software engineering practices and more!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store