Contract functions

Once the web3 object is correctly created and simplecontractinstance is created, calls to the contract functions can be made easily as shown in the following example:

function callMatchertrue() 
{ 
var txn = simplecontractinstance.Matcher.call(12); 
{ 
}; 
 
console.log("return value: " + txn); 
} 
 
function callMatcherfalse() 
{ 
var txn = simplecontractinstance.Matcher.call(1);{ 
}; 
console.log("return value: " + txn); 
} 

Calls can be made using simplecontractinstance.Matcher.call and then by passing the value for the argument. Recall the Matcher function in solidity code:

function Matcher (uint8 x) returns (bool) 

It takes one argument x of type uint8 and returns a Boolean value, either true or false. Accordingly, the call is made ...

Get Mastering Blockchain - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.