ethers.jsメタマスクとCoinbaseWallet、TronLinkウォレット接続方法

ヒント:記事作成後に目次を自動生成することもできますが、生成方法については右のヘルプを参照してください。


1. MetamaskとCoinbaseWalletウォレットの接続方法

const provider = new ethers.providers.Web3Provider(window.ethereum);
const accounts = await provider.send("eth_requestAccounts", []);//返回accounts [0]是钱包地址

2. TronLinkウォレット接続方法

const provider = new ethers.providers.Web3Provider(window.ethereum);
const accounts = await window.tronLink.request({
    
    method: 'tron_requestAccounts'})//返回accounts [0]是钱包地址

完了しました、若いプログラマの皆さん、スプレーしないでください。これが皆さんのお役に立てば幸いです。ご質問があればメッセージを残してください。

おすすめ

転載: blog.csdn.net/HHyuang/article/details/125636089