checkGoalReached

Once the funding goal is reached, the crowdfunding owner will collect of the all funds by running the checkGoalReached method.

The HTML is just a simple button, as shown in the following code:

<button type="button" id="checkGoal" class="btn btn-success">CheckGoal</button>

Similar to the fund function, we call the smart contract in JavaScript using the following code:

instance.checkGoalReached({ from: selectAcct, gas:3500000});

Here is the detailed logic:

  handleCheckGoal: function(event) {
event.preventDefault();
$("#displayMsg").html("");
var selectAcct = $('#accts').find(":selected").val();
App.contracts.CrowdFunding.deployed().then(function(instance) {
return instance.checkGoalReached({ from: selectAcct, gas:3500000});
}).then(function(result) {
App.loadProject();
}).catch(function(err) {
console.error(err);
$("#displayMsg").html(err);
});
},

The result will display as follows:

If you followed the whole example and run this step, congratulations! You are now able to write and run a crowdfunding DApp.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset