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


边栏推荐
- What are the preferential account opening policies of securities companies now? Is it actually safe to open an account online?
- Workplace four quadrant rule: time management four quadrant and workplace communication four quadrant "suggestions collection"
- Google Earth Engine(GEE)——Landsat 9影像全波段影像下载(北京市为例)
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
- B端电商-订单逆向流程
- [Chongqing Guangdong education] reference materials for labor education of college students in Nanjing University
- 八年测开经验,面试28K公司后,吐血整理出高频面试题和答案
- Detailed explanation of VBScript (I)
- 蓝牙芯片ble是什么,以及该如何选型,后续技术发展的路径是什么
- Properties of expectation and variance
猜你喜欢

疫情封控65天,我的居家办公心得分享 | 社区征文

自動生成VGG圖像注釋文件

ROS learning (10): ROS records multiple topic scripts
![[NLP] a detailed generative text Abstract classic paper pointer generator](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[NLP] a detailed generative text Abstract classic paper pointer generator

Sometimes only one line of statements are queried, and the execution is slow

Notes on hardware design of kt148a voice chip IC

Kt148a voice chip IC user end self replacement voice method, upper computer

Dictionaries

Shardingsphere jdbc5.1.2 about select last_ INSERT_ ID () I found that there was still a routing problem

HDL design peripheral tools to reduce errors and help you take off!
随机推荐
One side is volume, the other side is layoff. There are a lot of layoffs in byte commercialization department. What do you think of this wave?
RPD出品:Superpower Squad 保姆级攻略
Properties of expectation and variance
Kt148a voice chip instructions, hardware, protocols, common problems, and reference codes
【Hot100】23. 合并K个升序链表
An analysis of the past and present life of the meta universe
Use IDM to download Baidu online disk files (useful for personal testing) [easy to understand]
【871. 最低加油次数】
[译]深入了解现代web浏览器(一)
B端电商-订单逆向流程
After 65 days of closure and control of the epidemic, my home office experience sharing | community essay solicitation
KT148A语音芯片使用说明、硬件、以及协议、以及常见问题,和参考代码
[cloud native topic -49]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - basic processes and steps
【Hot100】21. Merge two ordered linked lists
在券商账户上买基金安全吗?哪里可以买基金
[real case] trap of program design - beware of large data
CRM Customer Relationship Management System
Sometimes only one line of statements are queried, and the execution is slow
Start practicing calligraphy
Automatic reading of simple books