-
Notifications
You must be signed in to change notification settings - Fork 57
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
Pattern/anti-pattern guide #2
Comments
Another example: Attempt to keep contracts reactive rather than active. If someone wants something from the contract, they should invoke an appropriate transition themselves. For instance, if the owners of a multi-signature wallet have approved the transfer of some money to a recipient, rather than transferring the money upon the last signature, one should let the recipient invoke the transition that executes the transfer. |
Good point on the part that the recipient should invoke the transition that executes the transfer. It helps to ensure that the recipient has access to the wallet address during the withdrawal process, and prevents the possibility of funds being sent to an address that no one has access to. Always favour pulls over push if possible. |
We could use a guide to patterns/antipatterns in Scilla.
Examples:
Don't use ping-pong between contracts. Instead, attempt to complete everything in one contract before invoking transitions on the other contract. If the second contract for some reason discovers a problem, then throw an exception (or otherwise cause an execution error), so that the entire chain of invocations are rolled back.
Avoid using the
size
operation, as it requires reading the entire map from the state. Instead, manually maintain a size counter, and use a dedicated procedure to update the map and the counter together, so that they are always kept in sync.The text was updated successfully, but these errors were encountered: