Dread 4 years ago
parent
commit
b4103d18c9
  1. 17
      utils/EthUtil.js

17
utils/EthUtil.js

@ -12,15 +12,16 @@ if (typeof web3 !== 'undefined') {
let eth = { let eth = {
// //获取主币eth余额 // //获取主币eth余额
getBalance: async function(address) { // getBalance: async function(address) {
web3 = new Web3(new Web3.providers.HttpProvider(systemConfiguration.constant.ethNode)); // web3 = new Web3(new Web3.providers.HttpProvider(systemConfiguration.constant.ethNode));
console.log("查询余额:",address) // console.log("查询余额:",address)
let balance = await web3.eth.getBalance(address); // let balance = await web3.eth.getBalance(address);
console.log("余额:",balance) // console.log("余额:",balance)
return Number(balance) / Math.pow(10, 18); // return Number(balance) / Math.pow(10, 18);
}, // },
// //获取eth代币币余额 // //获取eth代币币余额
// getTokenBalance: async function(address, contract) { // getTokenBalance: async function(address, contract) {
// console.log(address, contract) // console.log(address, contract)
@ -74,7 +75,7 @@ let eth = {
// 获取bms,bmdt,usdt/erc余额 // 获取bms,bmdt,usdt/erc余额
getTokenBalance: async function(address, contract, success) { getTokenBalance: async function(address, contract, success) {
web3 = new Web3(); web3 = new Web3();
const data = { const data = {
'jsonrpc': '2.0', 'jsonrpc': '2.0',
'id': '1', 'id': '1',
'method': 'eth_call', 'method': 'eth_call',

Loading…
Cancel
Save