-
Notifications
You must be signed in to change notification settings - Fork 76
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
Why do we need to add 4 bytes of random characters when interacting with contracts? #107
Comments
I'm by no means an expert here, but I believe it is needed to generate the tx.id properly |
@ppedziwiatr I don't think the data field is required for generating tx.id. For example, tx https://viewblock.io/arweave/tx/iCLuc7Aj3xFOOWX5qFZCz5UVRTVn8k6quM2ouiockHA don't have data field (Size 0B). |
To be more precise - I believe it is required to ensure the uniqueness of the tx ids (in case two transactions with exact same parameters would be posted) - which in case of SmartWeave is crucial... The flow goes like that (from the links that I've pasted in previous response):
The dataToSign is generated like that:
So - just in (probably very rare - but still possible) case, that all of the parameters of two transactions are the same - the randomly generated data increases the chance of generating unique txId. That's my understanding, but probably someone from core Arweave team will be able to explain this better. |
@ppedziwiatr Thank you for your further detailed explanation. |
When I looked at the source code, I found the following snippet:
Does anyone know why we need the random string?
SmartWeave/src/contract-interact.ts
Line 302 in 23ed88b
The text was updated successfully, but these errors were encountered: