I have created 2 contracts in solidity and trying to deploy the contract using (geth console, mist browser). Seller and Buyer.

In seller contract, I am creating seller name, productquantity, perunitcost. In the buyer contract, I am creating buyer name. Now I want to read the data of seller in the buyer contract, so that the buyer can make a purchase. How can I read data from one smart contract to another? Kindly help

  • so, did you manage to implement it? and is it just me or do i only see errors in the gif posted? spent almost a week now with solidity, having gone through all the docs, and what not before that and barely see anything functional..
    – Martyn Nyx
    Commented Feb 6, 2018 at 11:50

1 Answer 1


It's pretty easy, you can refer to another contract by address and call its functions if they are public:

 contract Foo {
    uint public value = 123;

  contract Bar {
  Foo foo;
    function MyContract(address otherAddress) {
      foo = Foo(otherAddress);
    function getFooValue() constant returns(uint){
      return foo.value();

See the fiddle in action: https://ethfiddle.com/T-9cXyBwgI enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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