0

I as trying to add methods in a contract, but it got so big that i couldn't deploy it with truffle. Now i need to create an otehr contract that will be called instead of the original contract to process data stored in the original contract as state variable.

The variable i am going to process is a mapping.

I am trying to do somehting like this :

contract Original {

mapping(bytes32 => Person) private Persons;

 /* many structs and methods here */
}

contract SecondContract {
   function processdata(){
     /* here i want to process the data stored in the mapping in the first contract */
   }
}

how do i get the link between the two contracts and be able to process that data ?

0

If I understand correctly, you just want to access the data stored in Original. If that's the case, you can do something like this:

contract Original {
  mapping(bytes32 => Person) public persons;
}

contract SecondContract {
  Original original;

  function SecondContract(address ofOriginalContract) {
    original = Original(ofOriginalContract);
  }

  function processData(bytes32 someBytes) {
    Person entry = original.persons[someBytes];
    // do something with entry
  }
}

Notice that I made persons a public mapping, so we can access it from another contract.

  • That is something i did already, but the problem that i can't add anything more to my contract, because it will not get deployed on the ganache-cli (due to size). so adding a second contract next to the original contract won't be different from adding processData function to the original contract – Kaki Master Of Time Mar 6 '18 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.