Post
Share your knowledge.
How to handle randomness restriction in PTB?
I came across an issue where I can't execute multiple commands following a random command in the PTB. It seems that the commands following a Random
command can only be TransferObjects
or MergeCoins
. Is there a workaround like an UnsafeRandom
, or is the only option to develop our own PRNG
?
- Move CLI
Answers
1This restriction is intentionally enforced to guard against PTB-based composition attacks. You can find more information in the documentation here: https://docs.sui.io/guides/developer/advanced/randomness-onchain#programmable-transaction-block-ptb-restrictions. Unfortunately, there isn't an 'UnsafeRandom' object available that would allow you to bypass this restriction.
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.

- ... SUIderiss+5
- ... SUIRamirez+5
- ... SUIElvin CLONE +5
- ... SUI
- ... SUI
- ... SUI
- ... SUIBritain+2