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?

you have to copy/paste the chain ID you get from the “get_info” command.
try to use “127.0.0.1” in Host and be sure the chain ID you get from command its the same your pasting on scatter.

2 Likes

On the Scatter Connect lesson,

I’m getting the following error, yet I believe I have the netowrk setup with the correct chainid.

localhost/:1 Uncaught (in promise) {type: “no_network”, message: “This user does not have this network in their Scatter.”, code: 402, isError: true}

Scatter in open and I am logged in and looking at the network eosio network i created in scatter. Not sure what I am doing wrong.

here is my main.js code…

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() {

});

cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f thats my example chain ID, will not work for you or anyone…only for me, you must get your own chain ID and configure it on your Scatter and main.js code.

const network = ScatterJS.Network.fromJson({
    blockchain:'eos',
    //this chain ID is personal, get your own chain ID!
    chainId:'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f',
    host:'127.0.0.1', 
    port:8888,
    protocol:'http'
});

please read carefully, you need to run this command in order to get YOUR nodeos chain ID

curl http://localhost:8888/v1/chain/get_info
1 Like

Hi @ivga80 and @thecil . I have installed the Scatter app in my Mac and configured it to connect to my local EOSIO node. I have imported some keys into Scatter and Scatter was able to detect the accounts related to those keys. So it seems like the connection between Scatter App and nodeos is working properly.
But I am having problems trying to connect the Web App to Scatter using scatter-js library.
I am using the code cloned from Filip’s github. I just changed the chain_id to the proper value in my local installation. When I run the app, I always get the alert from this line

if(!connected) return alert("No Scatter Detected!");

Also in the console, I get many network errors when the app tries to connect to localhost and local.get-scatter.com. There also some WebSocket connection errors.
Do you know what is happening?
Best regards,
Jefferson

hi @jmsofarelli, can you please post the log from the console? or a screenshot?

If you post the log please use the “Preformatted Text” button and paste the code inside. Like this:

i am happy preformatted text, please use me.
1 Like