For a simple contract:
pragma solidity ^0.4.11;
contract Test {
uint private val;
function getVal() constant returns(uint) {
return val;
}
function setVal(uint newVal) payable {
val = newVal;
}
function() {
val++;
}
}
getVal will be called from web3.js something like this:
contract.getVal.call(function(err, val) {
//
});
setVal will be called from web3.js something like this:
contract.setVal.sendTransaction(newVal,
{
gas: gas,
from: web3.eth.defaultAccount
},
function(err, result) {
//
});
How to trigger unnamed function from Javascript? Is it possible?