Post
Share your knowledge.
How to manage PTB restrictions on randomness in SUI?
I'm encountering a limitation with PTB where it restricts pulling in commands after using Random. I want to execute other commands within PTB. Is the only option here to develop a custom PRNG, or is there an 'UnsafeRandom' accessible for overcoming this?
- Move Script
Answers
2This restriction is actually there for security purposes to prevent PTB-based composition attacks. According to the documentation, there's no 'UnsafeRandom' object available for use to work around these constraints. You might have to consider developing your own custom Pseudorandom Number Generator (PRNG) if you need more flexibility.
The restriction is intended and thoroughly explained in the SUI documentation here: https://docs.sui.io/guides/developer/advanced/randomness-onchain#programmable-transaction-block-ptb-restrictions. It's done to ensure safety and integrity within the system.
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.