-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement getTransactionId
for transfers
on the Predicate
class
#1451
Comments
transfer
before sending itgetTransactionId
for transfers
getTransactionId
for transfers
getTransactionId
for transfers
on the Predicate
class
Although adding this If const transaction = contract.functions
.transfer(amountToTransfer, BaseAssetId, someAddress)
.callParams({
forward: [amountToForward, BaseAssetId],
})
.txParams({
gasPrice: 1,
gasLimit: 1,
variableOutputs: 1,
});
const request = await transaction.getTransactionRequest();
// before sending
console.log('gasLimit: ', request.gasLimit);
console.log('gasPrice: ', request.gasPrice);
console.log('Tx ID: ', hashTransaction(request, 0));
// sending
const { gasUsed } = await transaction.call();
// after sending
console.log({ gasUsed }); |
Either way, instead of getting the TX ID like this: const transaction = contract.functions.xyz();
const request = await transaction.getTransactionRequest();
const txID = hashTransaction(request, 0); We could have something more straightforward: const transaction = contract.functions.xyz();
const txID = transaction.getTransactionId(); This would eliminate the need to use This rationale applies to both |
No required but related: |
Given this example:
One might need to get the transaction ID before sending the transaction:
The problem is that the
transfer
method creates aScriptTransactionRequest
,funds
it, andsends
in the same call.To intercept the request and compute the transaction ID before it's sent, we must fragment this chain-of-action and expose the request instance in isolation via a method utility or something similar, enabling one to modify it before
submitting
the transaction and evengetTransactionId()
before callingsubmit()
.From this:
To something like this:
And then this:
Warning
Remember to roll this update in two phases:
Add method
getTransferTransactionId()
and keeptransfer()
as is, but with a deprecation noticeImplement
.transfer().getTransactionId().submit()
The text was updated successfully, but these errors were encountered: