I want to sign and verify a transaction offchain, but I can't really find a proper example/documentation online from start to finish that explains the whole process. Can somebody point to some reference?
If not, and if you do know how to do this, Can you illustrate it with a simple example that would sign a transaction to call the following function of a contract? and take into account that the verifier should be a different account than the signer.
contract simpleContract {
function simpleContract() public {
creator = msg.sender;
}
uint public value;
function testingStateChannel(uint simpleValue){
value=simpleValue;//function to be called in offline signed transaction
}
function getSimpleValue() view public returns (uint){
return value;
}
}
I would appreciate some solution that signs using Web3j (nodejs) or alternatively geth solidity.
Best Answer
For those of you who are also looking for this. Actually it is not exactly what I wanted in the question but it works perfectly for my requirements.
What I do is essentially signing some data, not the transaction, and then retrieving the data from the smart contract, so it is basically the same.
For the geth verify and check signatures, this is the code:
Then, in the solidity code, the same check as offline can be done in the following way: