EOS Dapp Programming

Welcome to the discussion thread about this lecture section. Here you can feel free to discuss the topic at hand and ask questions.

@filip - me again!!! For the scatter setup, you need to go into Networks and add your local net i.e. http://localhost:8888 otherwise your accounts that were created locally on you Mac will not be added. It took me a few mins messing around with scatter to spot this one.

Again, thanks for your help as always - really appreciated.

Cheers, Seamus.

Thanks for adding that. I will add that to the course.

1 Like

hello friends, im having a little issue with my linux server, want to know i someone can help me…

i deploy the python webserver has the eos course 201 says (python3 -m http.server )
i can see my localhost:xxxx on my firefox browser, but i got a msg that is not letting the scatter pop up the login window.

so firefox devs console says: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://local.get-scatter.com:54506/. (Reason: CORS request did not succeed).

and says the same with different ports used from scatter, now, IMO i think scatter could have an issue with HTTP servers? or do i have to create somekind of exception?

thank you guys. i cant continue with the course since i dont know if my web server is properly working.

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. localhost:8000
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://local.get-scatter.com:51506/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://local.get-scatter.com:53006/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://local.get-scatter.com:54506/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://local.get-scatter.com:56006/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:53005/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:51505/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:54505/. (Reason: CORS request did not succeed).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:56005/. (Reason: CORS request did not succeed).
Scatter Connected main.js:26:11
ReferenceError: ScatterJs is not defined main.js:28:19

The CORS errors are not a problem. I get them as well and I still get scatter to work. You seem to be having another issues, if you read at the bottom of your error message it says “ScatterJs is not defined main.js:28:19”. So there seems to be an issue with your code, can you post your code here so I can help you further?

yes, its your dapp-master-template, from the github link you post in the lesson, the main.js mentioned in my problem, its that main.js from the template, and yes, there’s no ScatterJs defined in the file, other 2 “.js” files (core and other) mention the same variable, but none of those define it, i try defining the variable with a simple [var ScatterJs = “”;] OR [var ScatterJS;] and its still not working…

Code im using on my main.js:

eosio@ubuntu:~/contracts/dogcontract/dapp-template-master$ sudo cat main.js

ScatterJS.plugins( new ScatterEOS() );

const network = ScatterJS.Network.fromJson({
    blockchain:'eos',
    chainId:'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f',
    host:'127.0.0.1',
    port:8888,
    protocol:'http'
});

const contractConfig = {
  code: "",
  scope: "",
  dogTableName: "",
  balancesTableName: "",
  symbol: ""
}

var eos;
var rpc;
var account;

ScatterJS.connect('DogDapp', {network}).then(connected => {
  if(!connected) return alert("No Scatter Detected");
  console.log("Scatter Connected");

  const scatter = ScatterJs.scatter;
  window.ScatterJS = null;

  scatter.login({accounts: [network]}).then(function(){
    account = scatter.account('eos');
    console.log(account);
  });
});

$(document).ready(function() {

});

Scatter is detected by the dapp template(so i guess or validate that my scatter network config for my local node is working), problem is that is not showing the scatter popup window to choose wich account to log in, i already import my priv keys to my scatter app, create an identity for 2 accounts (dogcontract & dogecoadmin). what might should i miss?

UPDATE: fixed the problem with my main.js, look the code post it, my problem is a variable that i miss call “scatterJs” and should be “ScatterJS”.
Now im having this msg: uncaught exception: Object

FINAL UPDATE FIX: problem was on “const scatter = ScatterJs.scatter;” should be “const scatter = ScatterJS.scatter;”.

Also, i check my scatter network config, in chain ID you must put the real chain ID you get from:
curl http://localhost:8888/v1/chain/get_info
In Scatter network config, you must paste the chain ID from that command into the scatter network config, now its looks like this:

Name: EOS Local.
Host: 127.0.0.1
Protocol: http
Port: 8888
Chain ID: cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f

No, I used my template when testing and it works fine. We don’t need to import Scatter or define Scatter in our js file. We import it into our window scope in the index.html file. Do you have that file according to the template as well? Or maybe it’s working now for you?

On which line in the code do you get your new error?