Dapp Introduction

Hey @Oussama

Which version of python have you installed on your pc?

On your powershell type:

python --version
And take note of the version.

Then:

python3 --version
And take note of the version.

Let me know,
Dani

Hi I fixed the problem, Python wasn’t installed as it should be, thank’s.

1 Like

Nice to read @Oussama :slight_smile:
Happy coding

Hi
I’m having the same issues.
I followed the step twice but still not getting the contract instance on console.log.
Yes I have my contract deployed on Ganache and it is running.

Hi guys,

It looks like Chain ID is a mandatory field now when adding the local host network on Metamask. How do we acquire this chain ID, and what is the significance of the chain ID ?

Thanks!!

  • Christian

Hey @Kalminkou

Can you post your main.js? Also which browser are you using?

thanks

hi there, none of @filip python commands are woring for me. :(.

Downloaded python 3.9 and it doesnt recognise my command.

Help please.

1 Like

Hi Christian,

You put any number and when you submit you’ll get an error message with a suggested chain Id. You use that one.
It’s how I manage to get the chain Id.

3 Likes

Hey @Rob_McCourt, hope you are well.

Could you please try to run python on windows console? (type “cmd” on the search bar to run the windows console). If you got the same error, probably python does not install correctly.

Now when you installed python, did you checked an option to add python to the “PATH” environment (or something like that).

If not, uninstall python, run the installer again and check that before installing it there will be a check box that mention something to add python to the PATH environment, then you should be able to run the same commands on the console.

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

Carlos Z.

3 Likes

Hi Guys!

Just want to share another alternative for running local server (in case you have problem running python). You can also do it like the following. It works as well.

  1. Open your Terminal, go to your project folder
  2. Run npm init
  3. Run npm install lite-server --save-dev
    –> lite-server is a lightweight server for frontend development
    –> reference: https://www.npmjs.com/package/lite-server
  4. Go to your package.json file. Under “scripts”, add `“start”: “lite-server”
  5. On your project root-folder, run npm run start

You will have your local server up and running! I hope it helps! :slight_smile:

Screenshot 2020-11-26 at 12.36.04 AM

@kalminkou thanks for the answer!!! I checked and there are 6 entries asking for the same question in the last 23 days and no answers from the team :astonished: :triumph: :yawning_face:

@gabba I 'm trying to read your post, since I got the same problem than @tungtien , but the browser displays a blank page :sweat_smile: … can you please copy the answer down here??

Please I need help!1

great ill try that now my good man…

Hope all is well with you friend.

p.s is there a wget cmd for downloading Python ?

further p.s and could you help me understand what PATH is doing. I see alot of that when i try to set up validators and i keep running in to that. I’ve not fully understood in the past.

Thanks Carlos

i clicked the box and it still didnt work in CMD CLI but… i went back to Powershell and did the same command and it did ? I mean what the hell ? lol

Anyone or @dan-i (since you helped well last time) know if these warnings I am getting on the browser (chrome) inspect console for metamask of any concern. Some of them have to do with Q4 2020 where we are today. I got to the point in the get data section where I get the console log of the data but when I updated the code to show in the Get Your Data form area it still only shows me the console log area when I click get data (sometimes when the console.log(res) code is commented out so I suspect the main.js code is not updating…)

Please see warnings in picture below:

Hi Rob! Glad it works out for you! :slight_smile:
I forgot to mention that you need to run the command in Termnal (for Linux OS) / Powershell (for Windows OS). In Windows, Command Prompt is different from Powershell.
To me, Powershell is like big brother of Command Prompt which is better! :smiley:
Here is some article about the differences:
https://www.howtogeek.com/163127/how-powershell-differs-from-the-windows-command-prompt/

1 Like

hi @dan-i Im having the same issue as @tungtien had ( Dapp Introduction ) , but Iam having problems loading the link with the solution: https://forumtest.ivanontech.com/t/creating-contract-instance-main-js-doesnt-affects-html-page/17525/4 … could you please help me out, I am having the exact same results as he had. My code for main.js is:

I checked the contract address from ganache, I have everything well cofigured


var web3 = new Web3(Web3.givenProvider);
var contractInstance;

$(document).ready(function() {
    window.ethereum.enable().then(function(accounts){
        contractInstance = new web3.eth.Contract(abi, "0xd9c2886F5e5Ed2714C00fE6F0f9B5a338Df0D4B7", {from: accounts[0]});
        console.log(contractInstance);
    });
});

Hi @acf
I came across this previously. And, I think I might be able to help regarding the warning Metamask will stop injecting web3.

[SUMMARY]
Nothing to worry at all about the warning because in the course, @filip is using window.ethereum (most of current modern browser already support this API).

Now, regarding to history (the explanation regarding the warning)…

Previously (until now), Metamask injects web3.js in the browser. Therefore, without even import web3.js library (simply in your browser console), you can use web3. Latest version of web3.js injected by Metamask is v.0.2.x. Meanwhile, latest version of web3.js now is v.1.0.x. It is not impossible for Metamask to update its injected web3.js version. But, it requires major changes, which is why they (Metamask) stop injected web3.js since currently mostly modern browser support Ethereum API.
You can read the details here :
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md
https://medium.com/metamask/breaking-changes-to-the-metamask-provider-its-happening-eebc91fff1a7

I hope it is helpful! :smiley:

@dan-i @thecil please correct me if I miss anything. Thanks! :pray:

Willys

Thanks @W1LL for the explanation. Now I know the warnings aren’t the reason why the Dapp is having issues running which is helpful! However, today I tried it again and now the add your data area is returning warnings after metamask confirmation. I have ganache running, python server running, truffle people contract compiled and migrated. Its confusing because I have got the whole thing to work almost completely in the past, up to get your data through console.log but I dont know why I cannot replicate it. Also tried using the other index truffle addresses via metamask… Please see the browser error below along with my server updates below. If you need anything else please let me know.

Hey @acf

These are usual metamask warnings about the way metamask is injected.
You can replace eth.enable wtih ethereum.request({ method: 'eth_requestAccounts' });
Check the docs here: https://docs.metamask.io/guide/ethereum-provider.html#table-of-contents

Give it a try.

Regarding the delay in updating, I agree that something python does that.

cheers,
Dani