Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

How to do it...

In order to read data from smart contracts, we will have to perform these steps:

  1. Create a contract instance with the ABI and the deployed address. If you are using web3.js v0.2x.x, use the following methods to create an instance:
// Create a contract objectvar MyContract = web3.eth.contract(<ABI>);

// Create an instance with address
var contractInstance = MyContract.at("<Address>");

For those who are using the upcoming version of web3js ( v1.x.x), use the following method to create an instance:

var contractInstance = new web3.eth.Contract(    "<ABI>",    "<Address>");
  1. Read data from the smart contract using the call method. This executes the code in the Ethereum Virtual Machine (EVM) and returns the value. This method does not ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content