Preventing a function from being called in the same transaction

In the instance two parties have the same Capability on a method, how would you all recommend ensuring that a resource method cannot be called in the same transaction? My current thought is to track the block that the method is called the first time and asserting that the block height of the successive call is greater than the originally recorded height. Can anyone think of a simpler/more elegant solution?
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni SOP2y ago
Agreed that enforcing different block height is not the same as enforcing different transaction. I'm trying to make calls to unsafeRandom() safer by requiring that the call including unsafeRandom() occurs in a different transaction. Imagine I have a method guessDiceRoll() and rollDice(). As you might guess, rollDice() includes a call to unsafeRandom(). To cheat the game, a user could form a transaction that requires the dice roll number they desire so that their guess matches the result of unsafeRandom(). To prevent this cheating vector, we could require that guessDiceRoll() occurs in a separate transaction than rollDice(). My question is then, how would we enforce the requirement that these two methods are called in separate transaction?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Giovanni S
Giovanni SOP2y ago
Commit reveal is a good idea in a two party setup. Though I’d like to construct a setup that doesn’t require a backend - just a local client & contract Thanks for the write up @bluesign, I’ll take a closer look today
Want results from more Discord servers?
Add your server