I have gone through the docs of ethereum and truffle as well. I had created a contract for more understanding related to contracts and its compilation and deployment on local network.

But I have specific requirement that I want to fetch some sort of data from blockchain public network and want to display it on website and generate reports based on that data.

How can I get the use data from 3rd party contract. Please refer below example to understand the scenario.

So, how this can be done w/o creating a contract ?

Eg. I want to get latest NASDAQ share price ups and downs of the current day and want to generate a chart dynamically on website.

  • Above link is related to pulling data from website to contract, but my question is to pull data from blockchain network to website. – Bhavik Nov 29 '17 at 7:34
  • could you give more information? What kind of info you want from the blockchain? Last block number? gas price? – Luiz Soares Nov 29 '17 at 11:10
  • For Eg. You have created one contract in which you are storing/maintaining latest public share prices for the day. So I want those prices from you. As there is a concept of Gas price which I need to pay you while I am using your services, but I am stuck here that how I would make a call to your services/contract methods. – Bhavik Nov 30 '17 at 3:17

So this really depends on the contract, if the contract implemented a public method or a public state variable then it's possible for you to get the data.

contract SimpleFetch {
    uint public fixedData = 12345;

    function get() public constant returns (uint) {
      return 12345;

    function balanceOf(address _owner) constant returns (uint balance) {
      return 1;

The above variables and functions could be called by anyone. You mentioned stock prices, so I put the balanceOf as an example there because all erc20 tokens implement this. And it is something you can call.

play with it yourself in a fiddle: https://ethfiddle.com/ZWww_YXa-3

  • It is correct that when data member is public then I can use that. But with what medium, I mean using ABI to access those methods OR else any other source of communication. – Bhavik Nov 30 '17 at 9:22
  • of course you need to know the interface of the contract. that is the whole point of ERC20, so that the token interface is known without needing to manually find out – cappy Dec 3 '17 at 7:59

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.