繁体   English   中英

如何从独立的 node.js 应用程序使用 ethers.js 连接到 Metamask 钱包?

[英]How can I connect to a Metamask wallet using ethers.js from a standalone node.js application?

我不知道该怎么做。 我看过一些关于 ethers.Wallet.fromMnemonic 的文档,但是 ethers 如何知道我的钱包是元掩码钱包? 或者,如果钱包提供商无关紧要(是吗?),它如何知道其地址?

然后我想与 BSC 上的流动性池进行交互有什么不同吗? 我的意思是在钱包方面。 钱包可以在 multiple.networks 上使用吗?

var web3 = require("web3")
var ethers = require("ethers")

async function MetaMask() {
    

    privateKey = "Your wallet privateKey";

    account = new ethers.Wallet(privateKey)

    console.log(account)

    //from mnemonic

     mnemonic = "Your Mnemonic"

     const wallet = new ethers.Wallet.fromMnemonic(mnemonic)

     console.log(wallet)

 
}

MetaMaskAddress = MetaMask()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM