当前位置:网站首页>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.


边栏推荐
- 什么叫在线开户?现在网上开户安全么?
- Want to ask, is there any discount for opening an account now? Is it safe to open an account online?
- Istio deployment: quickly start microservices,
- Share several map bed websites for everyone to share pictures
- [NLP] a detailed generative text Abstract classic paper pointer generator
- KT148A语音芯片ic的软件参考代码C语言,一线串口
- Shardingsphere jdbc5.1.2 about select last_ INSERT_ ID () I found that there was still a routing problem
- How to realize the function of detecting browser type in Web System
- Function, function, efficiency, function, utility, efficacy
- upload-labs
猜你喜欢

励志!大凉山小伙全奖直博!论文致谢看哭网友

RPD出品:Superpower Squad 保姆级攻略

After writing 100000 lines of code, I sent a long article roast rust

Istio deployment: quickly start microservices,

Dictionaries

Kt148a voice chip IC software reference code c language, first-line serial port

c语言链表--待补充

After 65 days of closure and control of the epidemic, my home office experience sharing | community essay solicitation

Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)

Postman interface test practice, these five questions you must know
随机推荐
Py's interpret: a detailed introduction to interpret, installation, and case application
Cs5268 perfectly replaces ag9321mcq typec multi in one docking station solution
KT148A语音芯片ic的开发常见问题以及描述
【Kubernetes系列】kubeadm reset初始化前后空间、内存使用情况对比
What are the benefits of multi terminal applet development? Covering Baidu applet, Tiktok applet, wechat applet development, and seizing the multi platform traffic dividend
【Hot100】23. 合并K个升序链表
CRM客户关系管理系统
【Hot100】23. Merge K ascending linked lists
SBT tutorial
Postman interface test practice, these five questions you must know
蓝牙芯片ble是什么,以及该如何选型,后续技术发展的路径是什么
burp 安装 license key not recognized
Overview of browser caching mechanism
pytorch 模型保存的完整例子+pytorch 模型保存只保存可训练参数吗?是(+解决方案)
Automatic reading of simple books
【JS】获取hash模式下URL的搜索参数
[cloud native topic -49]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - basic processes and steps
How my mother-in-law and daughter-in-law get along
Postman download and installation
AcWing 181. Turnaround game solution (search ida* search)