EOS Dapp Programming

Hi! I am back in business with the Academy! Glad to be here :slightly_smiling_face:

I picked up where I left off, namely at Dapp Programming > Get Dogs.

When I am calling the getDogs() function (line 33 of the main.js file), I am not getting the expected response in the console with three rows with the dogs that Bob owns, I am not getting the JSON object form, but instead, I am getting an error in the console:
asyncToGenerator.js:6 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

JSON_error

I googled the error, and it seems that this happens because when the request is made to the server, the response is HTML instead of JSON.

Do you have any idea why I am getting this error and how to fix it? @thecil @filip

Here is my code at this stage from 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: "dogcontract",
  scope: "dogcontract",
  dogTableName: "dogs",
  balancesTableName: "balances",
  symbol: "DOGCOIN"
}

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');
    rpc = new eosjs_jsonrpc.JsonRpc(network.fullhost());
    getDogs();
  });

});

function getDogs(){
  rpc.get_table_rows({
    json: true,
    code: contractConfig.code,
    scope: contractConfig.scope,
    table: contractConfig.dogTableName,
    index_position: 2,
    key_type: "name",
    lower_bound: account.name,
    upper_bound: account.name
  }).then(function(res){
    console.log(res);
  })
}

$(document).ready(function() {

});

Thank you!

@swisscrypto glad to know you are back! now I might need to check your entire main.js file, i’m checking mine and looks exactly has yours, just that i used a function login in a button to log in with my scatter.

Please try to share me your entire main.js so i can review it.
Here is part of mine, just to verify that everything looks good for you

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: "dogctrissuer",
  scope: "dogctrissuer",
  dogTableName: "dogs",
  balancesTableName: "balances",
  symbol: "DOGCOIN"
}

const scatter = ScatterJS.scatter;
var eos;
var rpc; //fetch data from blockchain
var account;
//initialize function to scatter and webpage functions
ScatterJS.connect('DogDapp', {network}).then(connected => {
  //check if scatter is running
  if(!connected) return alert("No Scatter Detected");
  console.log("Scatter Connected");


  window.ScatterJS = null;


});//end ScatterJS.connect function

function logIn(){
  //scatter login popup window
  scatter.login({accounts: [network]}).then(function(){
    account = scatter.account('eos');
    //get data from blockchain into a Json
    rpc = new eosjs_jsonrpc.JsonRpc(network.fullhost());
    //initialize eos object to create transactions
    eos = scatter.eos(network, eosjs_api.Api, {rpc});
    //get table data functions
    getAccount();
    getBalance();
    getDogs();

  });

}//end logIn
function logOut(){
  scatter.logout({accounts: null}).then();
}//enf logOut

//get name account
function getAccount(){
  $("#Account").empty();
  var AccId = document.getElementById("Account");
  var AccName = account.name;
  AccId.innerHTML = AccName;
}//end getAccount

//function to get data from blockchain tables
function getDogs(){
  rpc.get_table_rows({
    json: true,
    code: contractConfig.code,
    scope: contractConfig.scope,
    table: contractConfig.dogTableName,
    index_position: 2,
    key_type: "name",
    lower_bound: account.name,
    upper_bound: account.name
  }).then(function(res){
    console.log(res);
    populatedoglist(res.rows);
  })
}//end getDogs()

//wait until html page is loaded and apply some logic to objects
$(document).ready(function() {
  //Add dog button function
  $("#add_button").click(addDog);
  //Delete dog button function
  $("#del_button").click(deleteDog);
  //Delete ALL button function
  $("#del_all_button").click(deleteAll);
  //Deposit coins into contract
  $("#deposit_button").click(deposit_coin);
  //logIn and logOut buttons
  $("#login_button").click(logIn);
  $("#logout_button").click(logOut);
});

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Hey @thecil, great to see you too! :smiley:

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: "dogcontract",
  scope: "dogcontract",
  dogTableName: "dogs",
  balancesTableName: "balances",
  symbol: "DOGCOIN"
}

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');
    rpc = new eosjs_jsonrpc.JsonRpc(network.fullhost());
    getDogs();
  });

});

function getDogs(){
  rpc.get_table_rows({
    json: true,
    code: contractConfig.code,
    scope: contractConfig.scope,
    table: contractConfig.dogTableName,
    index_position: 2,
    key_type: "name",
    lower_bound: account.name,
    upper_bound: account.name
  }).then(function(res){
    console.log(res);
  })
}

$(document).ready(function() {

});

In the meantime, I will try with your code and let you know how it is working.

Thanks,
Vincent

1 Like

@thecil With your code, it is working! The Scatter app is popping up as expected (see screenshot below).

I was following Filip’s instructions in the Get Dogs video and modifying the main.jscode along the way, because I like learning by practice in doing the modifications myself in the code while following the video. At some stage of the video, Filip used the getDogs() function and got a response in the console with three rows and the dogs. Instead, I got an error, as I posted above. But this is fine, I will continue with your code and follow the videos along.

Thanks for your support, as always! :+1: :grinning:

1 Like

Glad to know is working for you, the first list of error you receive is from the scatter, those happens usually, is the wallet trying to connect through different sockets, now you are still getting the unexpected token issue, maybe you should check your Local EOS config, verify that your protocol is set on http not https.

Also you have not imported the private keys of your EOS accounts into scatter, try to import one (which have an account created through cleos).

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

Carlos Z.

1 Like

OK, in this case I am ignoring these errors.

Yes, I am still getting the unexpected token issue, as follows:

unexpected_token

OK, I checked my Local EOS config, and my protocol is set on http, as you can see:

Actually, I did import the public-private keypair of my EOS account created through cleos, please see below a screenshot of my Scatter wallet:

I keep following the course and watching the videos (I just finished the Add Dog Section), but I cannot get the three rows with the dogs under “Your Dogs”, and I cannot add a dog either, I think the issues above hinder me to do so.

Here is a screenshot of my DogDapp web page with the Scatter box that popped up:

Here is my main.js code now:

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: "dogctrissuer",
  scope: "dogctrissuer",
  dogTableName: "dogs",
  balancesTableName: "balances",
  symbol: "DOGCOIN"
}

const scatter = ScatterJS.scatter;
var eos;
var rpc; //fetch data from blockchain
var account;
//initialize function to scatter and webpage functions
ScatterJS.connect('DogDapp', {network}).then(connected => {
  //check if scatter is running
  if(!connected) return alert("No Scatter Detected");
  console.log("Scatter Connected");


  window.ScatterJS = null;


});//end ScatterJS.connect function

function logIn(){
  //scatter login popup window
  scatter.login({accounts: [network]}).then(function(){
    account = scatter.account('eos');
    //get data from blockchain into a Json
    rpc = new eosjs_jsonrpc.JsonRpc(network.fullhost());
    //initialize eos object to create transactions
    eos = scatter.eos(network, eosjs_api.Api, {rpc});
    //get table data functions
    getAccount();
    getBalance();
    getDogs();

  });

}//end logIn
function logOut(){
  scatter.logout({accounts: null}).then();
}//enf logOut

//get name account
function getAccount(){
  $("#Account").empty();
  var AccId = document.getElementById("Account");
  var AccName = account.name;
  AccId.innerHTML = AccName;
}//end getAccount

//function to get data from blockchain tables
function getDogs(){
  rpc.get_table_rows({
    json: true,
    code: contractConfig.code,
    scope: contractConfig.scope,
    table: contractConfig.dogTableName,
    index_position: 2,
    key_type: "name",
    lower_bound: account.name,
    upper_bound: account.name
  }).then(function(res){
    console.log(res);
    populateDogList(res.rows);
  })
}//end getDogs()

function populateDogList(dogs){
  var ul = document.getElementById("doglist");
  for (var i = 0; i < dogs.length; i++) {
    var li = document.createElement("li");
    li.appendChild(document.createTextNode(dogs[i].id + ": " + dogs[i].dog_name + ", " + dogs[i].age));
    ul.appendChild("li");
  }
}

function addDog(){
  var dogName = $(""#dog_name").val();
  var dogAge = $(""#dog_age").val();

  eos.transact({
    actions: [{
      account: contractConfig.code,
      name: 'insert',
      authorization: [{
        actor: account.name,
        permission: account.authority
      }]
      data: {
        owner: account.name,
        dog_name: dogName,
        age: dogAge
      }
    }]
  }, {
    blocksBehind: 3,
    expireSeconds: 30
  }).then(function(res){
    console.log(res);
  }).catch(function(err){
  alert(err);
  })
}

//wait until html page is loaded and apply some logic to objects
$(document).ready(function() {
  //Add dog button function
  $("#add_button").click(addDog);
  //Delete dog button function
  $("#del_button").click(deleteDog);
  //Delete ALL button function
  $("#del_all_button").click(deleteAll);
  //Deposit coins into contract
  $("#deposit_button").click(deposit_coin);
  //logIn and logOut buttons
  $("#login_button").click(logIn);
  $("#logout_button").click(logOut);
});

Please note that starting from your code, I also added the populateDogList(dogs) and addDog() functions, following along what Filip explained in the Get Dog and Add Dog sections.

Here is also my HTML code:

<html>
  <head>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

    <script src="dist-web/scatterjs-core.min.js"></script>
    <script src="dist-web/scatterjs-plugin-eosjs2.min.js"></script>
    <script src='dist-web/eosjs-api.js'></script>
    <script src='dist-web/eosjs-jsonrpc.js'></script>
    <script src='dist-web/eosjs-jssig.js'></script>
    <script src="main.js"></script>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <title>Dog Dapp</title>

  </head>
  <body>
    <div class="jumbotron jumbotron-fluid">
      <div class="container">
        <h1 class="display-4">Dog Dapp</h1>
        <p class="lead">We store your dogs in a safe and decentralized way.</p>
      </div>
    </div>

    <div class="container">
      <div class="row">
        <div class="col">
          <h2>Your Dogs</h2>
          <ul id="doglist">

          </ul>
        </div>
      </div>

      <div class="row">
        <div class="col">
          <h2>Add dog</h2>
          <div>
            <label>Dog name</label>
            <input type="text" id="dog_name">
          </div>
          <div>
            <label>Dog age</label>
            <input type="number" id="dog_age">
          </div>
          <button type="button" class="btn btn-primary" id="add_button">Add</button>
        </div>
      </div>
    </div>
  </body>
</html>

If you can help me move forward in the course, your assistance is welcomed! Thanks :slight_smile:

All your code looks good, the problem is on the scatter, might wanna have to close it and open it again, sometimes it goes buggy by not showing you the account, if you have imported a private key that belongs to an account, try to click on the refresh button on the scatter to show the account.

Be sure that your nodeos is running without any problem since basically your scatter connect to your local node which is your nodeos instance.

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

Carlos Z.

1 Like

Yes sure, Scatter happens to be buggy sometimes, I understand it is in the process to be improved… :hammer_and_wrench: … but it’s fine, I will move forward with the course and do my best to do the exercises. In the meantime, I will google the JSON “unexpected token” error and if needed, check with the EOSIO Developers Community.

Right now, I am not on my Ubuntu laptop, so I will try tomorrow to close/open and refresh Scatter to see the account displayed. I am quite sure that my nodeos was up and running, but I will check again.

Thanks!

1 Like

Hi! I moved forward with the course, but I am still getting the “Unexpected token” error:

Unexpected_token_26Sep20

Here is a screenshot of my dApp window:

Now following the course and Filip’s instructions, I added the addDog() function in my code.

When I try to insert a dog name and the dog age in the text boxes and click the Add button (the Add Dog feature of the dApp), I am getting another error:

transact_error

I checked line 94 of my JS code: eos.transact({ and verified the whole addDog() function by comparing it to Filip’s code in the video, but I didn’t spot any error.

I reached the end of the Add Dog Table Update section. I would like to do the Assignment - Remove Dog exercise, but I cannot test the result of my code in my dApp, because of these two errors, that don’t allow me to see and refresh the list of dogs and to use the Add Dog feature, so I cannot test my code.

Here is my main.js code now:

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: "dogctrissuer",
  scope: "dogctrissuer",
  dogTableName: "dogs",
  balancesTableName: "balances",
  symbol: "DOGCOIN"
}

const scatter = ScatterJS.scatter;
var eos;
var rpc; //fetch data from blockchain
var account;
//initialize function to scatter and webpage functions
ScatterJS.connect('DogDapp', {network}).then(connected => {
  //check if scatter is running
  if(!connected) return alert("No Scatter Detected");
  console.log("Scatter Connected");


  window.ScatterJS = null;


});//end ScatterJS.connect function

function logIn(){
  //scatter login popup window
  scatter.login({accounts: [network]}).then(function(){
    account = scatter.account('eos');
    //get data from blockchain into a Json
    rpc = new eosjs_jsonrpc.JsonRpc(network.fullhost());
    //initialize eos object to create transactions
    eos = scatter.eos(network, eosjs_api.Api, {rpc});
    //get table data functions
    getAccount();
    getBalance();
    getDogs();

  });

}//end logIn
function logOut(){
  scatter.logout({accounts: null}).then();
}//enf logOut

//get name account
function getAccount(){
  $("#Account").empty();
  var AccId = document.getElementById("Account");
  var AccName = account.name;
  AccId.innerHTML = AccName;
}//end getAccount

//function to get data from blockchain tables
function getDogs(){
  rpc.get_table_rows({
    json: true,
    code: contractConfig.code,
    scope: contractConfig.scope,
    table: contractConfig.dogTableName,
    index_position: 2,
    key_type: "name",
    lower_bound: account.name,
    upper_bound: account.name
  }).then(function(res){
    console.log(res);
    populateDogList(res.rows);
  })
}//end getDogs()

function populateDogList(dogs){
  $("#doglist").empty();
  var ul = document.getElementById("doglist");
  for (var i = 0; i < dogs.length; i++) {
    var li = document.createElement("li");
    li.appendChild(document.createTextNode(dogs[i].id + ": " + dogs[i].dog_name + ", " + dogs[i].age));
    ul.appendChild("li");
  }
}

function addDog(){
  var dogName = $("#dog_name").val();
  var dogAge = $("#dog_age").val();

  eos.transact({
    actions: [{
      account: contractConfig.code,
      name: 'insert',
      authorization: [{
        actor: account.name,
        permission: account.authority
      }],
      data: {
        owner: account.name,
        dog_name: dogName,
        age: dogAge
      }
    }]
  }, {
    blocksBehind: 3,
    expireSeconds: 30
  }).then(function(res){
    // SUCCESSFUL ADD
    getDogs();
  }).catch(function(err){
  alert(err);
  })
}

//wait until html page is loaded and apply some logic to objects
$(document).ready(function() {
  //Add dog button function
  $("#add_button").click(addDog);
  //Delete dog button function
  $("#del_button").click(deleteDog);
  //Delete ALL button function
  $("#del_all_button").click(deleteAll);
  //Deposit coins into contract
  $("#deposit_button").click(deposit_coin);
  //logIn and logOut buttons
  $("#login_button").click(logIn);
  $("#logout_button").click(logOut);
});

Your help would be appreciated @thecil @ivga80 @filip

Please kindly note that I submitted the “Unexpected token < in JSON at position 0” issue to the EOS.IO Stack Exchange forum. Let’s see if I get an answer soon.

Hello @swisscrypto, glad to know your ok. sorry for the long delay.

Now in your code your probably have an error on addDog() function, in your data: should be listed in the same exactly way that is in your table.
I tried with this order and it works for now:
data: { dog_name: dogName, age: dogAge, owner: account.name }

Remember to check on the cleos if the account have any dog.

cleos get table <account> <scope> <table-name>

Also, you can not add dogs with the contract owner (dogctrissuer if that your contract deployed account). So I advice to create another account (example: bob), transfer some dogecoins to that account and try it on your dapp.

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

Carlos Z.

1 Like

Hi Carlos, thank you for your reply!

I listed my data: in the same order as you suggested:

data: {
    dog_name: dogName,
    age: dogAge,
    owner: account.name
}

Unfortunately, I am still getting the same errors:

dogdapp_errors

The Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0 error when I am loading the dapp homepage.

The Uncaught TypeError: Cannot read property 'transact' of undefined error when I am trying to use the dapp to add a dog.

I posted the Unexpected token issue in the EOS.IO Stack Exchange and got the following answer: “That unexpected token < is a strong clue that the response was HTML instead of JSON. While you expected to get JSON”.
I also saw this suggestion when I googled the error.
But I don’t know how to correct my code accordingly and to make the dapp work properly, so that I can see my dogs and add them.

I checked on the cleos, and I don’t have any account associated with my public/private keypair:

cleos get accounts EOS5dnHK432yiTvnmavNvPQ7QpjMJkxp6nRgk8XAD58v1RU46RfDt { "account_names": [] }

I cannot find the gemeos account I created in May associated with my new public key EOS5dnHK432yiTvnmavNvPQ7QpjMJkxp6nRgk8XAD58v1RU46RfDt.

This is what I get when I am using `cleos get table :

It used to work in May (see Payable Functions - Discussion), but today it appears the account is not here anymore.

Along this EOS 201 course, I think I really have been carefully following the instructions in the videos, but for some reason, I have not been able to make the dapp run properly on my laptop, with my environment.

This is OK :slightly_smiling_face:, I think I will simply follow the last videos until the end of the course.

All the best!

1 Like

@thecil Having problems with curl: (7) Failed to connect to localhost port 8888: Connection refused

after using curl http://localhost:8888/v1/chain/get_info

1 Like

Hello @cherrybluemoon, hope you are great.

Which OS are you using?
If linux, you could check which program is using the port 8888 with netstat commands.
sudo netstat -ltnp
that will give you a list of ports that are being used and by which process (PID is the ID of the process)

Then you can use pkill command to kill the process…example: pkill 2626 means process kill ID(number).

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Hi @thecil,

My OS is mac. So I found and used sudo lsof -i -n -P | grep TCP to check ports. After I used pkill nodeos, then nodeos start command. I still received the error msg. Will keep troubleshooting. Hopefully I can find a solution. :grinning: :nerd_face:

Now I tried sudo lsof -PiTCP -sTCP:LISTEN which now I can see ports, but still cannot query or connect

node      92797 cherrybluemoon   35u  IPv4 0x3d24e3b81f42d40b      0t0  TCP localhost:50952 (LISTEN)
node      92797 cherrybluemoon   36u  IPv4 0x3d24e3b81f15466b      0t0  TCP localhost:50953 (LISTEN)
node      92797 cherrybluemoon   37u  IPv4 0x3d24e3b7f9e208cb      0t0  TCP localhost:45623 (LISTEN)
node      92797 cherrybluemoon   38u  IPv4 0x3d24e3b81d17eeeb      0t0  TCP localhost:59623 (LISTEN)
cherrybluemoon@Markandrews-MacBook-Pro ~ % curl http://localhost:50592/v1/chain/get_info
curl: (7) Failed to connect to localhost port 50592: Connection refused
cherrybluemoon@Markandrews-MacBook-Pro ~ % curl http://localhost:50593/v1/chain/get_info
curl: (7) Failed to connect to localhost port 50593: Connection refused
1 Like

Ok i’m not really an expert on MAC OS, but i think you have an issue with the firewall, probably, i’m not complete sure.

Maybe this could help https://www.macworld.co.uk/how-to/mac-software/how-open-specific-ports-in-os-x-1010-firewall-3616405/

Hope you find this useful.
If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

I think it may have something to do with eosio.cdt. What I found when searching a user solved it using eosio/eos-dev:v1.2.3
Also this link https://cmichel.io/how-to-install-an-old-package-version-with-brew/ has a how to for old package version.
A little confusing for me.
However in Step 1 Installing Binaries for this course, (I am not sure but v1.8.1 may have something to do with solving port issue)

brew tap eosio/eosio
brew install eosio
(make sure you get v1.8.1)

I get this:

brew install [email protected]
Error: No available formula or cask with the name "[email protected]".
=> **Searching for a previously deleted formula (in the last month)...**
Error: No previously deleted formula found.
==> **Searching for similarly named formulae...**
Error: No similarly named formulae found.
==> **Searching taps...**
==> **Searching taps on GitHub...**
Error: No formulae found in taps.

Ok based on their instructions:
First you have to remove the actual eosio, brew remove eosio.cdt.
Then download the package of the old version, extract it and install it.

Now, are you sure that you are in the same folder when extracting the package file?
I mean you have to create a local folder to extract the package, then you should go into the folder and run the brew install [email protected] for example.

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

Carlos Z.

I did not get the needed results with my chainid with the command Filip used
curl http://localhost:8888/v1/chain/get_info

But I used the following instead and it worked just fine. Hopefully this helps anyone in the future!
curl http://127.0.0.1:8888/v1/chain/get_info

1 Like

I have following action in my smartcontract:

ACTION uploadfile1 (name creator, vector<uint8_t> content, string filename)

I’m trying to push action from my Swift application using following code:

struct uploadFile: Codable {
    var creator: EosioName
    var content: [Int8]
    var filename: String
}

    let testArr = Array(repeating: Int8(20), count: 10)
    let data = uploadFile(creator: try! EosioName("tibackbone"),
                          content: testArr,
                          filename: theFileName)

    rpcProvider = EosioRpcProvider(endpoint: endpoint)
    guard let rpcProvider = rpcProvider else {
        print("ERROR: No RPC provider found.")
        return
    }

    let serializationProvider = EosioAbieosSerializationProvider()
    let signatureProvider = try! EosioSoftkeySignatureProvider(privateKeys: privateKeys)
    transactionFactory = EosioTransactionFactory(
        rpcProvider: rpcProvider,
        signatureProvider: signatureProvider,
        serializationProvider: serializationProvider
    )
    
    let transaction = transactionFactory?.newTransaction()
    let action = try! EosioTransaction.Action(
        account: EosioName(accountName),
        name: EosioName("uploadfile1"),
        authorization: [EosioTransaction.Action.Authorization(
            actor: EosioName(accountName),
            permission: EosioName("active"))
        ],
        data: data
    )

    transaction?.add(action: action)

    transaction?.signAndBroadcast { result in
        switch result {
        case .failure (let error):
            print("*** TRANSACTION ERROR")
            print("---- ERROR SIGNING OR BROADCASTING TRANSACTION")
            print(error)
            print(error.reason)
        case .success (let info):
            if let transactionId = transaction?.transactionId {
                print("Transaction ID \(transactionId)")
        default: break
        }
    }

When i’m running this code i’m receiving following error:

*** TRANSACTION ERROR ---- ERROR SIGNING OR BROADCASTING TRANSACTION Error was encountered in SerializationProvider. Unable to pack json to bin. Expected string

Can anyone suggest me where i’m wrong and what i’m missing.

Thanks to everyone in advance!

Hello everyone

I am struggling with the following Error:
I’ve set up the Dog Dapp according to the videos. I can log into a Scatter account when the site launches, but I cant use any of the functions.
When trying to add a Dog i receive the following error:
0.0.0.0:8000
Error: fetching abi for dogcontract: Read past end of buffer

Couldn’t really solve it with google nor the forum so far.
I’ve found people having similar errors due to performance issues, which wouldn’t really make sense to me tbh.
Has anyone got an Idea?

Thanks alot!