In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
How to introduce Ethereum-web3.js in weex, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Require ("babel-core/register"); require ("babel-polyfill"); import Web3 from 'web3'export default {name: "testWeb3", data () {return {web3: {}, host: "http://127.0.0.1:7545", address:' 0x50b04982c7a08De4Fe3e9F34dcEC1b06b835aE13percent, nonce:'', balanceWei:null} }, methods: {createWeb3 () {let web3 = new Web3 () let provider = new Web3.providers.HttpProvider (this.host) web3.setProvider (provider) return web3}, created () {this.web3 = this.createWeb3 () / / if (! this.web3.currentProvider.connected) {/ / throw new Error ('Please check the host or interenetment of the block chain') / /} this.web3.eth.net.isListening ((err, res) = > {console.log (res)}) / / Test this.web3.eth.net.isListening () .then ((data) = > {if (data) {console.log ('isconnected:',data)}}) .catch ((err) = > {throw new Error (' Please check the host or interlocking of the block chain')}) / / get the current network ID this.web3.eth.net.getId ((err, res) = > {console.log (res) / / 5777}) / / View account list this.web3.eth.getAccounts ((err,res) = > {console.log ("View account list:", res)}) / / query miner account this.web3.eth.getCoinbase (function (error, result) {if (error) {console.error (error)) } else {console.log ("query miner account:", result);}}) / / method for obtaining the balance-this.web3.eth.getBalance (this.coinbase, (err, res) = > {if (! err) {let balance = this.web3.utils.fromWei (res, 'ether')) Console.log ("this coinbase1:", this.coinbase) console.log ("getBalance1:", balance) / / 100this.balanceWei = balance} else {console.log (err);}}); / / method II let _ self = this to obtain the balance Async function getBalance (coinbase) {try {let rs = await _ self.web3.eth.getBalance (coinbase); return rs;} catch (err) {console.error ("error:", err);}} getBalance (this.coinbase) .then (res = > console.log ('this.coinbase balance:', res) / / 10000000000000000000000; / New account let newAccount = this.web3.eth.accounts.create (); console.log ("New account:", newAccount) let info = this.web3.eth.accounts.encrypt (newAccount.privateKey, '12345678'); console.log ("encrypt Information of New account:", info) / / create a new account personal.newAccount this.web3.eth.personal.newAccount ('! @ superpassword', (err, res) = > {let newAddress = res Console.log ('new account created by personal:', newAddress) / / account unlocked this.web3.eth.personal.unlockAccount (newAddress, "! @ superpassword", (err, res) = > {console.log (newAddress+ "unlocked successfully:", res) / / true});}) / / check the account list this.web3.eth.getAccounts ((err,res) = > {console.log ("View account list:", res)});}}; is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.