Reputation: 21
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
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