Ethereum javascript paquete web contrato inteligente

Estoy tratando de enviar el valor del menú desplegable html al contrato inteligente, el valor se extrae de la función js pero no puedo agregarlo a la función SetVote, la ejecución se interrumpe allí.

Html:
 <div class="dropdown">
            <button class="btn btn-vote btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
              Dropdown button
            </button>
            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
              <a class="dropdown-item" href="#">value1</a>
              <a class="dropdown-item" href="#">value2</a>
              <a class="dropdown-item" href="#">value3</a>
            </div>
          </div>


JavaScript:

 App = {   web3Provider: null,   contracts: {},


  init: function() {

    console.log("inside init");


    return App.initWeb3();   },

  initWeb3: function() {

    console.log("inside initWeb3");

    // Is there an injected web3 instance? if (typeof web3 !== 'undefined') {   App.web3Provider = web3.currentProvider; } else {   // If no injected web3 instance is detected, fall back to Ganache   App.web3Provider = new Web3.providers.HttpProvider('http://127.0.0.1:9545'); } web3 = new Web3(App.web3Provider);  

    return App.initContract();   },

  initContract: function() {

    console.log("inside initContract");

    $.getJSON('voting.json', function(data) {
      // Get the necessary contract artifact file and instantiate it with truffle-contract
      var votingArtifact = data;
      App.contracts.voting = TruffleContract(votingArtifact);

      // Set the provider for our contract
      App.contracts.voting.setProvider(App.web3Provider);

      // Use our contract to retrieve and mark the adopted pets
     // return App.markAdopted();
    });

    return App.bindEvents();   },

bindEvents: function() {

  $(document).on('click', '.btn-res', App.GetVote); 

 //$(document).on('click', '.btn-vote', App.SetVote);

 $(".dropdown-menu a").click(function(){var vote = $(this).text(); });
   console.log("voted value",vote);
   App.SetVote(vote);

         },


SetVote: function(account) {

  var votingInstance;  
  //var vote="voteValue"

  App.contracts.voting.deployed().then(function(instance) {

    votingInstance = instance;

    return votingInstance.setVote(vote);   }).then(function() {

    // modal for successfully voting
    // open index page

  }).catch(function(e) {
    console.log("error in voting");   });

},

GetVote: function() {

   web3.eth.getAccounts(function(error, accounts) {
    if (error) {
      console.log(error);
    }

    var account = accounts[0];

    var self = this;

    var data;
    voting.deployed().then(function(instance) {
      data = instance;
      return data.getVote.call();
    }).then(function(value) {

      console.log(value);

      //table of winners
     //list of voters



    }).catch(function(e) {
      console.log(e);
      self.setStatus("Error getting balance; see log.");
    }); }); } }; $(function() {   $(window).load(function() {
    App.init();   }); });

Respuestas (1)

La forma en que lo veo es que la cuenta de parámetro SetVote no se envía al método de contrato setVote. Corrija sus variables y vea si se invoca su método de contrato.