Background
The current API is designed to only care for sending a transaction and waiting it to be mined. E.g.,
const data = await contract.postNote(...)
When this promise resolves, it means the transaction has been sent and mined.
This makes the following situation hard to handle:
- The app only needs to know that a transaction has been sent. For example, the app wants to distinguish the two steps so as to show the loading prompt as "Sending" and "Mining".
- The app wants to do
multicall which involves in multiple contract function getting encoded, sent, and mined.
Proposal
Chain methods are adopted to the new API. The new methods are:
.send()
.data()
- anything else?
The new API will go like this:
const fn = await contract.postNote(...) // only encodes the contract function
const tx = await fn.send() // sends transaction
const data = await tx.data() // waits the transaction to be mined and returns data
// or in chain
const data = await contract.postNote().send().data()
If the app wants to do multicall:
const fns = [contract.postNote(...), contract.postNote(...), contract.postNote(...)]
const multicallFn = await contract.multicall(fns).send().data()
Let me know what you think?
Background
The current API is designed to only care for sending a transaction and waiting it to be mined. E.g.,
When this promise resolves, it means the transaction has been sent and mined.
This makes the following situation hard to handle:
multicallwhich involves in multiple contract function getting encoded, sent, and mined.Proposal
Chain methods are adopted to the new API. The new methods are:
.send().data()The new API will go like this:
If the app wants to do
multicall:Let me know what you think?