Move.

Post

Share your knowledge.

farshad.
Mar 15, 2025
Expert Q&A

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
1
1
Share
Comments
.

Answers

1
Aliabee.
Mar 16 2025, 15:17

This 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.

1
Comments
.

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.

148Posts231Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.

Reward CampaignJune
We use cookies to ensure you get the best experience on our website.
More info