当前位置:网站首页>Web3js method to obtain account information and balance
Web3js method to obtain account information and balance
2022-07-02 20:23:00 【JackieDYH】
web3js file
web3 Browser check
if (typeof window.ethereum !== 'undefined') {
console.log('MetaMask is installed!');
}
- 1.
- 2.
- 3.
Get account information
// introduce
//<script src="./node_modules/web3/dist/web3.min.js"></script>
async function get(){
// Instantiation web3
window.web3 = new Web3(ethereum);
var web3 = window.web3;
// Request user authorization solve web3js Cannot be aroused directly Meta Mask Get user identity
const enable = await ethereum.enable();
console.log(enable,11)
// Authorize access to accounts
var accounts = await web3.eth.getAccounts();
// web3.eth.getAccounts().then((e)=>{console.log(e)})
// Take the first account
var myAccount = accounts[0];
console.log(myAccount, 1);
// Returns the balance of the account at the specified address
var balance = await web3.eth.getBalance(myAccount);
console.log(balance, 2)
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.


边栏推荐
- RPD出品:Superpower Squad 保姆级攻略
- Why do I have a passion for process?
- RPD product: super power squad nanny strategy
- 面试经验总结,为你的offer保驾护航,满满的知识点
- AcWing 340. Solution to communication line problem (binary + double ended queue BFS for the shortest circuit)
- 自动生成VGG图像注释文件
- 现在券商的优惠开户政策什么?实际上网上开户安全么?
- esp32c3 crash分析
- pytorch 模型保存的完整例子+pytorch 模型保存只保存可训练参数吗?是(+解决方案)
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
猜你喜欢

Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)

JASMINER X4 1U深度拆解,揭开高效省电背后的秘密

Conscience summary! Jupyter notebook from Xiaobai to master, the nanny tutorial is coming!

Spark source code compilation, cluster deployment and SBT development environment integration in idea
![[QT] QPushButton creation](/img/c4/bc0c346e394484354e5b9d645916c0.png)
[QT] QPushButton creation

Development skills of rxjs observable custom operator

API documentation tool knife4j usage details

【871. 最低加油次数】
[译]深入了解现代web浏览器(一)

编写完10万行代码,我发了篇长文吐槽Rust
随机推荐
B-end e-commerce - reverse order process
[cloud native topic -49]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - basic processes and steps
Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)
Cron表达式(七子表达式)
Kt148a voice chip IC software reference code c language, first-line serial port
For (Auto A: b) and for (Auto & A: b) usage
通信人的经典语录,第一条就扎心了……
浏览器缓存机制概述
How can testers do without missing tests? Seven o'clock is enough
c语言链表--待补充
Génération automatique de fichiers d'annotation d'images vgg
AcWing 1126. Minimum cost solution (shortest path Dijkstra)
JASMINER X4 1U深度拆解,揭开高效省电背后的秘密
Cron expression (seven subexpressions)
【QT】QPushButton创建
Outsourcing for three years, abandoned
CRM客户关系管理系统
「 工业缺陷检测深度学习方法」最新2022研究综述
burp 安装 license key not recognized
sense of security