4

I have buid a dapp with web3, truffle and metamask, which works perfectly fine.

Now, instead of using a wallet I want to create my own wallet using ether.js, but couldn't figure out a way to use ether.js with truffle.

Is it possible, if yes, how. Any lead will be appreciated

3

Truffle use Web3 by default and its injected inside as global dependency. You can't get rid of it, but you can install ether.js as dependency on your project.

truffle init

then you install your module

npm install --save ethers

and eventually you use it in your truffle tests

var ethers = require('ethers');

you can use the ethers library into your tests and then execute with truffle test command.

Consider that you wouldn't have the library if you use truffle develop, since only web3 would be injected.

  • I want to get rid of metamask. For that I need something which can do exactly what metamask is doing. Metamask injects web3 into your application but ether js does not do it. And without metamask's web3 I cant do any transaction. Is there any way I can use etherjs to make transactions from truffle? – Ujjwal Pandey Jun 7 '18 at 16:36
  • etherjs can be included in your application even if you don't use web3. You still need metamask to connect to the network (as far as I know) – mirg Jun 8 '18 at 9:04
  • Is there any way I can make dapp without metamask. If yes, Please share solutions – Ujjwal Pandey Jun 8 '18 at 16:30
  • No, in order to connect to the network you need a client (metamask, mist browser etc) – mirg Jun 9 '18 at 4:46
  • You can use etherjs and abolish metamask completely given you handle the wallet in app. Not advisable for public dapps but if you're working with a private chain it's not a big issue imo. – Nico Vergauwen Jun 13 '18 at 7:53
1

You can use etheres.js with Truffle, but you might want to consider using frameworks dedicated to ethers.js like Waffle

Waffle is like Truffle, but simpler, faster and sweeter. Also uses ethers.js :)

0

Ether.js supports several providers, which provide an abstraction to how application code connects to the blockchain; it's well documented here.

FWIW, you're also not limited to using truffle as a framework as you can just add ethers to any project via npm/yarn. Just saying.

0

Etherlime is also a framework based on ethers.js and there is a helpful migration guide - https://medium.com/limechain/etherlime-january-status-update-1af29f704b6f

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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