lee
lee

Reputation: 21

Is it possible to develop chrome extensions with web3.js or Ethers.js?

I want to develop an ethereum wallet chrome extension.

While developing a simple prototype, I noticed that the node.js module cannot be run directly from the chrome extension.

But I must use web3.js or ethers.js.

Is there any way to develop Chrome extensions using web3.js or ethers.js?

Upvotes: 2

Views: 2060

Answers (1)

mcanvar
mcanvar

Reputation: 475

Of course, when we check the packages of the MetaMask we will see both web3 & ethjs libraries which is also an extension:

// ...
    "web3": "^..."
// ...
    "ethjs": "^...",
    "ethjs-contract": "^...",
    "ethjs-ens": "^...",
    "ethjs-query": "^...",
// ...

What we might do either we can compile it via a tool like browserify or import the minified browser version like this(I tested it is working with metamask-extension-provider package*):

import Web3 from 'web3/dist/web3.min.js';

// or

const Web3 = require('web3/dist/web3.min.js');

*A specific version of provider for extensions, check its docs.

Upvotes: 2

Related Questions