I wrote a smart contract and deployed on my private Quorum. I use Web3j to generate java wrapper to call ABIs. For example,
// here is a smart contract function
function getMoney() external payable
{
Event_GotMoney(msg.value, now);
}
In my java, if I call like this
contract.getMoney(new BigInteger(100)).send();
// or
// contract.getMoney(new BigInteger(100));
I can always get Event_GotMoney event. However, if I want to call it continuously, like this, (asynchronized)
for(int i=0; i<100; i++)
contract.getMoney(new BigInteger(100));
I can't get 100 Event_GotMoney events. The interval of the timestamp in the event is 3 or 10 seconds(depends on the frequency of generating blocks). I guess the nonce isn't updated util a block generated. If my guess is correct, how can I call smart contract functions continuously? If not, is it a limitation or something?
Another small question, I use event observable functions provided by Web3j wrapper. It works well to get events, but it updates every 15 seconds. How could I modify the interval?
Any feedback would be appreciate.
do you know how to fix this problem, i meet the same problem
No, I didn't find any solutions or workarounds. I found it uses "pending" to get nonce. It shouldn't have this kind of issues. If you have any ideas, please share with me.
You can use FastRawTransactionManager and sendAsync() instead of send(). It will allow you to send many transactions asynchronously.
@dukei , I tried sendAsync() in my loop and I got the same result.
I found this could change the 15 seconds interval.
I found the solution, dukei is right.
Here is my code, @ChenYunerer for your reference,
FastRawTransactionManager fastRawTxMgr =new FastRawTransactionManager(web3, credentials, new PollingTransactionReceiptProcessor(web3j, pollingInterval, 40));
Contract contract = MyPersonalContract.load(contractAddr, web3, fastRawTxMgr, gasPrice, gasLimit);
Most helpful comment
I found the solution, dukei is right.
Here is my code, @ChenYunerer for your reference,