I am completely stuck

Thanks for the answer.
It 's good to know it’s just a visual bug.

Bjarni

Why am I not getting any help here? :frowning:
So I will try again, can anyone have a look into my Voting Project and see why the Voting and Approve Voter functions are not working?? The do work in Remix, but will throw errors in ganache and ropsten and truffle develop @Malik , @filip, @dan-i, @thecil @ivan ?

REPO
So the problem right now really leaves me puzzled, because the contract works fine in the console and in remix and also Unit tests pass. But the frontend will not work:
ErrorRPC
And when calling the approveVoters function I get this:
ErrorRPC

I suspect that the code is right, but there is some issue with the network ? I tried to run it on truffle develop as well as ganache.
Any help much appreciated @dan-i, @Malik, @filip, @thecil. I guess you guys are very busy as well. So if you find time, this is my first project I pushed so far on my own and I really learned a lot, from passing values between functions and languages to generating HTML from within javascript and looping async functions to retrieve data from public arrays. But when googling this errors I find very different opinions and solutions. Some say it is a bug in the client (ganache) and that problems with nonces are not easily solvable and so on… I hope to get your feedback on this. Thanks :slight_smile:

Hi @Bhujanga

This looks like a require statement that fails in your contracts.
Double check the requirements and also provide step by step how to reproduce the issue.

Reagards,
Dani

1 Like

If it would be a requirement issue it would also revert in remix and the console as well as the Unit Test, right? As I wrote, the contract is working as intended when unit testing, using in remix, and as well as directly in the console.
To replicate this issue: Get the repo, deploy it to ganache or run it in truffle develop, host a local server through python and open index.html on the port you hosted the server. Don’t forget to update the contract address in main.js
You can then try to approve a voter’s address through the frontend, or try to submit a vote, by clicking buttons.

Hi @Bhujanga

You are sending ether to a non-payable function therefore the contract reverts.
Keep in mind that the error code you saw is 99.9% related to a revert.

  function approveVoter(address voter) public {
    require(msg.sender == voteMaster, "Only voteMaster can access this function!");
    require(!voters[voter].didVote, "Voter already voted!");
    require(voters[voter].weight == 0);

    voters[voter].weight = 1;
  }

  var config = {
    value: web3.utils.toWei("1", "ether")
  }
  voteApp.methods.approveVoter(str).send(config)

Cheers,
Dani

2 Likes

Oh my @dan-i Dan-i !!! I can’t believe it! Thank you sooooo much :pray: :hugs: :hugs:
I didn’t see it! Such a st***** mistake! I feel embarrassed somehow, but also, very much relieved as THE CODE WORKS!!! :partying_face: :partying_face: :partying_face: I can’t tell you how good this feels! The first project I am working on my own! I went through many hours of “headache” :rofl: but it was all worth it. Dang! So frustrating at times, but so demanding when it works. Dev beginners have a hard life :sweat_smile:
Payable was all there was missing! This will stick in my mind probably forever now :rofl:

Hi, Carlos,
I am stuck with the console use on my laptop: here is the message I got, when trying commands posted in “how to use javascript console”:
Erreur dans les liens source : Error: NetworkError when attempting to fetch resource.
URL de la ressource : moz-extension://bfb96eb8-d3fc-4579-b9cb-f46478475988/contentscript.js
URL du lien source : …/sourcemaps/contentscript.js.map

Help, please!

1 Like

Hey @LioC, hope you are great.

Please provide an screenshot of the error you are facing in the console so i can understand it better :face_with_monocle:

Carlos Z.

Capture d’écran 2021-03-22 103946
Hi, Carlos

1 Like

Ok, you are trying to provide an entire HTML code, the console should not be used on that sense, its only to provide some few testing on a website or HTML file that you provide.

You could try to save all the HTML code into an HTML file (you code file should end with .html), then you can open it with a browser and check how it behaves, you can use the console to add non-permanent changes just to test code without saving or modifying the main file or code.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

2 Likes

OK, Carlos.
Thanks for quick answer.

1 Like

Hello everyone, I am looking for some help with this question. I Will highly appreciate your assistance! Thank you. :slight_smile:
What is the address with the path m/0/2 for the following wallet: zpub6nQF4m3JT6hTkQ4o9Vc8LDMQx7nMkT5CsnPgVHnnrpF9JHeP6ioboEK2CXB34Xn6nzqcJnLPuMqQaKqBhwvZR7GJNvSeRUpDpCaVu3N3stz

@ivan @thecil hope you are well. I have never coded before and I am very excited about the course. I know this is the start for me however I am struggling to open my simple html code on my browser every time I open it it just reads exactly as it reads in Atom with the tags and elements. What am I doing wrong

Hey @PartalosCrypto, hope you are great.

It would be great to provide an screenshot about the issue you are facing.
But i think that it could be that you just forgot to save your file with the proper format file.
So whenever you want to save a file has a HTML format, you must use .html at the end of the file name, something like fileName.html. (the same applies for javascript files .js).

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Thank you @thecil much appreciated. I will try that and if not I will attach a screen shot. :star_struck:

1 Like

Hi all, I hope someone can help me with the following detail:

In Ivan’s video on promises, he chooses to return the function constructTimeoutPromise rather than calling it. This detail isn’t explained and doesn’t seem necessary to me: Why do we have to return the value rather than simply calling on its functionality? I hope someone can clear this up. Thanks in advance for your time, much appreciated!

Screen Shot 2021-03-31 at 03.30.45

I’ve spent over 1 hour on this problem trying to get Ivan’s answer to work. I have a solution but it is not Ivan’s answer and it doesn’t use print formatting.

From Lesson 9, #8 Write a script to define two floating print variables: length and width. Give these variable values 10,101 and 3,843. Console.log using print formatting and the two variables: The rectangle is 10101 cm long and 3843 cm wide.

Ivan’s answer is: var length = 10.101; var width = 3.843; console.log(‘The rectangle is ${length} cm long and ${width} cm wide.’);

When I input that in the console, it prints

The rectangle is ${length} cm long and ${width} cm wide.

My solution prints correctly:

var length = 10100; var width = 3843; console.log("The rectangle is ", length, "cm long and ", width, “cm wide.”);

Please tell me why I can’t get Ivan’s solution to print correctly in the console. I read another student’s identical problem, but it was not solved other than to repeat Ivan’s solution. Thank you!

1 Like

Hey @Techno, hope you are ok.

Although your code is complete correct, the only difference is on which quote type are you using.

An example:

var myName = "Carlos";
// common old quotation
console.log("My name is ", myName);
// modern quotation
console.log(`My name is ${myName}`);

Check the difference on the quotes, the old one is "" while the method used by ivan is with curvy quotes ``.

Carlos Z

Cecil,

Thank you so much! I was using a single quote, and he is using a back tick. I have never used a back tick before and had to google to find it on the keyboard.

@thecil you are a lifesaver! I appreciate your answer and maybe it will help someone else too… Rosalie

1 Like

script var name = “value”; /script
is not functioning when refreshing html page on browser
i installed script package, that didn’t work. what am i missing.

Screen Shot 2021-05-17 at 3.57.32 PM
please help.

1 Like