I can’t figure out how to do this. I have seen some documentation talking about ethers.Wallet.fromMnemonic, but how does ethers know my wallet is a metamask one? Or, if the wallet provider is irrelevant (is it?) how does it know its address?
Does it make any difference that I want to then interact with a liquidity pool on BSC? I mean in terms of the wallet. Can a wallet be used on multiple networks?
Advertisement
Answer
JavaScript
x
25
25
1
var web3 = require("web3")
2
var ethers = require("ethers")
3
4
async function MetaMask() {
5
6
7
privateKey = "Your wallet privateKey";
8
9
account = new ethers.Wallet(privateKey)
10
11
console.log(account)
12
13
//from mnemonic
14
15
mnemonic = "Your Mnemonic"
16
17
const wallet = new ethers.Wallet.fromMnemonic(mnemonic)
18
19
console.log(wallet)
20
21
22
}
23
24
MetaMaskAddress = MetaMask()
25