TransWikia.com

Error while signing a transaction using nodejs wallet API?

EOS.IO Asked by sachin murali on November 24, 2021

I am building an eosdapp using nodejs code.I got the wallet api from the developers portal,but when i run the code i get the following error.

{"code":500,"message":"Internal Service Error","error":{"code":7,"name":"bad_cast_exception","what":"Bad Cast","details":[]}}

The nodejs code with input data(payload11) given below.

payload11 = 
[{
  "ref_block_num": blockno,
  "ref_block_prefix": ref_block,
  "expiration": timestamp,
  "actions": [{
    "account": "certcontract",
    "name": "issue",
    "authorization": [
    {
      "actor": "terminatoroo",
      "permission": "active"
    }],
  "data": bindata
}],
"signatures": []
},
[
requiredkey
],
"e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473"
]




var biz = JSON.stringify(payload11);

console.log(biz);
console.log("")
//console.log(payload1)
var options = { method: 'POST',
url: 'http://127.0.0.1:8888/v1/wallet/sign_transaction',
headers: { 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8' },body:biz};

request(options, function (error, response, body) {
if (error) throw new Error(error);

console.log(body);
});

One Answer

I think the issue is the payload11 variable is not valid JSON, specifically:

},    // Doesn't have a corresponding opening {
[
requiredkey         // Not in quotes, isn't connected to the key beneath
],
"e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473"
]

It should probably be something like this:

  "signatures": [],
  "requiredkey":"e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473"
}]

Answered by Phillip Hamnett - EOS42 on November 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP