I created a contract (in the Ropsten Test Net) for the most basic example described in this article: http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html
pragma solidity ^0.4.0;
contract SimpleStorage {
uint storedData;
function set(uint x) {
storedData = x;
}
function get() constant returns (uint) {
return storedData;
}
}
The following Javascript calls that contract:
var abi = [{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}];
var MyContract = web3.eth.contract(abi);
var myContractInstance = MyContract.at('0x51a5846DB9DEb1Cd72ccab36F825C06328a21b8C');
myContractInstance.set.call(1, function(error, result){
if(!error) {
console.log("#" + result + "#")
} else {
console.error(error);
}
})
myContractInstance.get.call(function(error, result){
if(!error) {
console.log("##" + result + "##")
} else {
console.error(error);
}
})
The "set" call does not work, because it requires "sendTransaction" instead of "call".
I have tried every combination of parameters in web3.eth.sendTransaction, and I continually get the following error message: "sendTransaction Invalid number of arguments to Solidity function"
I have read the API documentation (https://github.com/ethereum/wiki/wiki/JavaScript-API), which does not provide a good example for web3.eth.sendTransaction. Please do not provide just a theoretical explanation, or a requirement to install additional tools.
Please provide a specific javascript code example that has been tested, to show how I can use just javascript to execute the "set" function in the contract shown above.