I have a master contract which deploys instances of other contracts.
pragma solidity ^0.5.0;
pragma experimental ABIEncoderV2;
contract DataEntityContract {
DataEntity DE;
constructor(string memory _name,string[] memory _relatedEntities, string memory _date, string memory _fileName, string memory _annotations) public
{
DE = DataEntity(_name, 'URN', _fileName, new string[](0), _relatedEntities, 'references', _annotations, msg.sender, _date);
}
struct DataEntity {
//Event notifications;
string dataEntityName;
string rawFileURN;
string fileName;
string[] nameChangeHistory;
string[] sources;
string references;
string annotations;
address createdUpdateBy;
string when;
}
function editDE() public {
DE.annotations = "edited";
}
function getAnnotations() public view returns(string memory) {
return (DE.annotations);
}
}
contract FlattenedDEC
{
address owner;
string public name;
mapping (string => address) dataEntities;
string[] public dataEntityNames;
uint count = 0;
uint public DataEntitiesCount = 0;
mapping(uint => Lineage) public lineageInfo;
mapping(uint => DE) public DataEntities;
event DataEntityEdited(
string name,
string comments,
address editedBy
);
constructor() public
{
name = "DataEntityCatalogue Master Contract";
owner = msg.sender;
}
function createNewDataEntity(string memory _name, string[] memory _dataEntities, string memory _date, string memory _fileName, string memory _annotations) public returns(address _new){
DataEntityContract instance = new DataEntityContract(_name,_dataEntities, _date, _fileName, _annotations);
return address(instance);
}
function editDE(string memory _name) public{
DataEntityContract de = DataEntityContract(dataEntities[_name]);
de.editDE();
emit DataEntityEdited(_name, "edited", msg.sender);
}
Now, when I try to call the editDE method in FlattenedDEC or even in DataEntityContract from my dapp I am gettting a jsonrpc error but when I call the same from remix everything works fine.
Here is my react js code:
async editDataEntity(name){
const web3 = window.web3;
const networkId = await web3.eth.net.getId();
const networkData = await FlattenedDEC.networks[networkId];
const contract = web3.eth.Contract(FlattenedDEC.abi, networkData.address);
contract.methods.editDE().send({from: this.state.account})
.on('error',(error) => {
console.log("error: ", error);
})
.on('transactionHash', () => {
console.log("edited");
});
}
This is the error i get:
MetaMask - RPC Error: Error: [ethjs-rpc] rpc error with payload
{"id":6402969023659,"jsonrpc":"2.0","params":
["0xf9010e8203dc85746a528800836170d494ca9a565e46004c9e5f9b2ac2b4ca83d61814c20180b
8a4108770750000000000000060000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000064544495
445440000000000000000000000000000000000000000000000000000822d45a0186aa938713cc78d
fe0089d896b0890ffa693ad77fe521d4d3e5e454d2fbe600a045413f6b3d94d1df175ba42e7790e99
9fe3a97a44c91451632abb02789e10612"],
"method":"eth_sendRawTransaction"}