I'm trying to make a frontend of calling a function with an address attached:
function getAvailableAllocation(address _addr)
constant
returns (uint ethAvailableAllocation)
{
return investorActions.getAvailableAllocation(_addr);
}
Here is onSubmit function:
onSubmit = async event => {
event.preventDefault();
const accounts = await web3.eth.getAccounts();
await fund.methods.getAvailableAllocation(this.state.value).call({
from: accounts[0],
address: this.state.value
}).then(console.log);
Here is onSubmit form
<form onSubmit={this.onSubmit}>
<h4>Available allocation</h4>
<h5>Get the remaining available amount in Ether that an investor can subscribe for</h5>
<div>
<label>Your ethereum address</label>
<input
value={this.state.address}
onChange={event => this.setState({ address: event.target.value })}
/>
</div>
<button>Get available allocation</button>
</form>
When I use an address passed it consolelog the right result. Like so: fund.methods.getAvailableAllocation('0xbe4B62ac6C98bf755dBf217e24FA502A00eC9cf3').call
What I'm doing wrong?
this.state.address
instead ofthis.state.value
? – user19510 Dec 14 '18 at 19:00address: this.state.value
. – goodvibration Dec 15 '18 at 9:22then
, I suggest that you do something a little more explicit. For example:then(function(result, error) {console.log(JSON.stringify(result));});
. – goodvibration Dec 15 '18 at 9:23