#How to test transactions and account balances

4 messages · Page 1 of 1 (latest)

outer flare
#

I want to do something simple: require the sender to transfer a fee to the smart contract in order to make a move in a game. What's a good way to achieve this functionality and test the account balances?

rancid kayak
outer flare
#

Thanks! I'm not sure I completely understand. Can you point me to a reference or doc that explains this concept?

ebon hare
#

I assume this is more about testing than about creating something with ideal UX, so I'd not worry about avoiding slow block times.
I think you can achieve what you want by doing something like the deposit() method here: https://docs.minaprotocol.com/zkapps/how-to-write-a-zkapp#signing-transactions-and-explicit-account-updates
i.e., include logic like this in your method that makes a move.
(note: this.sender is not constrained in the proof to be the actual tx sender. it's an unconstrained public key the prover could choose. zkApp proofs can, in general, not make any assertions about the sender. but that doesn't usually matter though)