Batch Call snd Send Transactions
When we need to query many pieces of information or send many transactions, we may need to send many requests to the RPC server, and it may cause request limitation and low efficiency. So we provided batch methods for you to send a batch request at one time to avoid this case and improve efficiency.
Please see example from example_bulk
Batch query information
New
BulkCaller
BulkCaller.Cfx().XXX
(XXX means RPC methods) to append request, and the returned result and error are pointers for saving results after requests are sent.Besides
Cfx
, there are alsoDebug
,Trace
,Pos
methods for acquiring RPC methods for the corresponding namespaceBulkCaller.Execute
to send requests.The result and error pointer of step 2 are filled by request results
BulkCaller.Clear
to clear request cache for new bulk call action.
Batch call contract
New
BulkCaller
Use
abigen
to generate contract bindingThere is a struct called
XXXBulkCaller
(XXX means your contract name) for bulk call contract methodsXXXBulkCaller.YourContractMethod
to append request to its first parameter which isBulkCaller
instance created in step 1, and the returned result and error arepointersr for saving results after requests be sent.BulkCaller.Execute
to send requests.The result and error pointer of step 4 are filled by request results
BulkCaller.Clear
to clear request cache for new bulk call contract action.
It's ok to batch call normal RPC methods and contract calls by BulkCaller.
Batch send transaction
New
BulkSender
BulkSender.AppendTransaction
to append an unsigned transactionBulkSender.SignAndSend
to send requests. The transaction hashes and errors will be returned. All of them are slice with the same length of appended transactions.BulkSender.Clear
to clear request cache for new bulk send action.
Batch send contract transaction
Use
abigen
to generate contract bindingThere is a struct called
XXXBulkTransactor
(XXX means your contract name) for bulk send contract transactionsBulkSender.SignAndSend
to send requests. The transaction hashes and errors will be returned. All of them are slice with the same length of appended transactions.BulkSender.Clear
to clear request cache for new bulk send action.
Last updated