I prefer the ethers.js library to web3. Is there a way to configure truffle test to use ethers.js instead of web3?



2 Answers 2


Not just what you're asking, but may help. I am using etherlime - it's a framework based on ethers.js. There is a guide how to configure your project from truffle to etherlime and it includes a section for test migration. Hopes it would help - https://etherlime.readthedocs.io/en/latest/migration-from-truffle-guide.html.

Actually, I have wrote some tests using ethers.js but it is a little bit annoying when you need to change the signer(msg.sender) for some function execution. You have to connect a wallet to a contract every time you needed to use different sender.


You should be able to use Truffle's web3 instance, and extract the provider to use it with ethers.js.

let web3Provider = new ethers.providers.Web3Provider(web3.currentProvider, network);

Not the answer you're looking for? Browse other questions tagged or ask your own question.