I was able to create and deploy a contract locally to Ganache using Truffle. I could set and get a value successfully as well. I deployed this contract to both Rinkeby and Ropsten and was able to call the get function, but the set function failed with the error:
Error: Invalid JSON RPC response: ""
Using MyEtherWallet/MetaMask, I was able to call both get and set functions successfully on Rinkeby. Is there anything that jumps out as to why it would work locally, but not on the testnets?
Set function:
ProcessHistoryStoreInstance.setStore(
uuid,
attribute,
value,
{from: account}
).then(function(result) {
console.log('TX Hash: ' + result.tx);
response.status(200).json({success: true, msg: result.tx});
}, function(error) {
console.log('Error setting attribute: ' + error);
response.status(500).json({success: false, msg: error});
});
Get function:
ProcessHistoryStoreInstance.getFromStore.call(uuid, attribute).then(function(result) {
console.log('Result: ' + result);
response.status(200).json({success: true, msg: result});
}, function(error) {
console.log('Error getting attribute: ' + error);
response.status(500).json({success: false, msg: error});
});
Solidity contract:
pragma solidity^0.4.11;
import "./AttributeStore.sol";
contract ProcessHistoryStore {
AttributeStore.Data store;
function getFromStore(bytes32 _UUID, string _attrName) public constant returns (uint) {
return AttributeStore.getAttribute(store, _UUID, _attrName);
}
function setStore(bytes32 _UUID, string _attrName, uint _attrVal) public {
AttributeStore.setAttribute(store, _UUID, _attrName, _attrVal);
}
}