I am using truffle and Ganache. I wrote the following code in remix and its working. But when I use the same code with javascript I am getting runtime error
pragma solidity ^0.4.17;
contract Delegation {
//Structure definition to store various roles like IoT_Member.
//It will store permissions associated to the role.
struct RoleTypes {
bytes32[] permTypes;
uint index;
}
//Mapping to map role name to role information for the purpose of indexing
mapping (bytes32 => RoleTypes) role;
//Array to check the existance of role
bytes32[] chkRole;
//Function to check the existance of role
function checkRole(bytes32 _roleName) public view returns (bool) {
return (chkRole[role[_roleName].index] == _roleName);
}
}
Javascript:
var deleg;
Delegation.deployed().then(function(instance) {
deleg = instance;
return deleg.checkRole.call(web3.fromAscii(roleName));
}).then(function(value) {
//Something
});
Error:
Uncaught (in promise) Error: Invalid JSON RPC response: {"id":2,"jsonrpc":"2.0"}
at Object.InvalidResponse (app.js:10361)
at app.js:48396
at XMLHttpRequest.request.onreadystatechange (app.js:51022)