Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- App = {
- web3Provider: null,
- contracts: {},
- account: 0x0,
- init: function() {
- return App.initWeb3();
- },
- initWeb3: function() {
- if (typeof web3 !== 'undefined') {
- App.web3Provider = web3.currentProvider;
- } else {
- App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
- }
- web3 = new Web3(App.web3Provider);
- App.displayAccountInfo();
- return App.initContract();
- },
- displayAccountInfo: function(){
- web3.eth.getCoinbase(function(err, account){
- if(err === null){
- App.account = account;
- $('#accountId').text(account);
- }
- });
- return App.initContract();
- },
- initContract: function() {
- $.getJSON('Voting.json', function(votingArtifact) {
- App.contracts.Voting = TruffleContract(votingArtifact);
- App.contracts.Voting.setProvider(App.web3Provider);
- return App.reloadVoters();
- });
- },
- reloadVoters: function() {
- App.displayAccountInfo();
- }
- };
- $(function() {
- $(window).load(function() {
- App.init();
- });
- });
Add Comment
Please, Sign In to add comment