1

I'm trying to simulate a transaction on the public blockchain that invokes a contract's method with certain parameters. Then I want to make a follow-up transaction with some other method call.

I figured that I can use call() function in the JavaScript console to invoke a method without actually publishing a real transaction, e.g:

var abi = [...];
var contractAddress = "0x...";
var contract = web3.eth.contract(abi).at(contractAddress);
contract.updateSomething.call(...);    // change some values

The problem now is: How can I make another call that uses the updated state of the contract?

If I just use another call() it returns the old value, not the updated one.

...
contract.updateSomething.call(...);    // change some values
contract.readSomething.call();         // returns old value

1 Answer 1

0

You have to wait until the transaction is mined. One way to accomplish that is to make the method updateSomethig to generate an event, and to make your program listen such events. When the transactions is mined an event will be generated, and your callback will be called.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.