Unable to render inside (callback function) using react for web3.eth.subscribe

import React from ‘react’; import ReactDOM from ‘react-dom’; import Web3 from ‘web3’; class App extends React.Component { componentWillMount() { this.loadBlockchainData() } async loadBlockchainData() { var web3 = new Web3(Web3.givenProvider || ‘http://127.0.0.1:7545’) var network = await web3.eth.net.getNetworkType() var accounts = await web3.eth.getAccounts() var balances = await web3.eth.getBalance(accounts[0]) var block = await web3.eth.getBlockNumber() var blockHash = await…

Unable to render inside (callback function) using react for web3.eth.subscribe

import React from ‘react’; import ReactDOM from ‘react-dom’; import Web3 from ‘web3’; class App extends React.Component { componentWillMount() { this.loadBlockchainData() } async loadBlockchainData() { var web3 = new Web3(Web3.givenProvider || ‘http://127.0.0.1:7545’) var network = await web3.eth.net.getNetworkType() var accounts = await web3.eth.getAccounts() var balances = await web3.eth.getBalance(accounts[0]) var block = await web3.eth.getBlockNumber() var blockHash = await…

Cannot return a value from struct

In my contract I have: struct UserByAdress { address playerAddress; uint customerBalance; bool initialized; } mapping (address => UserByAdress) private playerByAddress; function returnCustomerBalance () public view returns (uint){ return (playerByAddress[msg.sender].customerBalance); } In my frontend: function customerBalanceOnContract (){ var customerBalanceOnContract = contractInstance.methods.returnCustomerBalance(); console.log(customerBalanceOnContract); return customerBalanceOnContract; } I however do not get back an integer “customerbalance” but…

Cannot return a value from struct

In my contract I have: struct UserByAdress { address playerAddress; uint customerBalance; bool initialized; } mapping (address => UserByAdress) private playerByAddress; function returnCustomerBalance () public view returns (uint){ return (playerByAddress[msg.sender].customerBalance); } In my frontend: function customerBalanceOnContract (){ var customerBalanceOnContract = contractInstance.methods.returnCustomerBalance(); console.log(customerBalanceOnContract); return customerBalanceOnContract; } I however do not get back an integer “customerbalance” but…