# Interesting case regarding fund collecting in Guessing Game on Plutus

**URL:** <https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907>\
**Category:** Smart Contracts\
**Tags:** plutus\
**Created:** [6 November 2020 11:32 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907 "2020-11-06T11:32:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phantom\_of\_the\_Opera](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/phantom_of_the_opera/32/23036_2.png) [@Phantom\_of\_the\_Opera](https://forum.cardano.org/u/Phantom_of_the_Opera)\
**Post date:** [6 November 2020 11:32 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907/1 "2020-11-06T11:32:49Z")

</div>

Hello everyone,  
I have been diving into Plutus Smart Contracts lately and one of the main things that I would like to understand better is when and how to use the `startWatching` function.  
For example in guess game on available on the [Playground](https://prod.playground.plutus.iohkdev.io/)  
it is necessary for the person who’s guessing to run StartGame before the number is locked.  
This is somewhat counter intuitive, and I had the following questions about the situation:

1. 

```
Is there anyway to just "extract" all funds from an address?

```

2. 

```
Why doesn't it know the outputs of the address of the game if used after lock?

```

3. 

```
Isn't this quite limiting in regards of what it is possible to achieve with Plutus smart contracts? What if a player only "knew" about the game after it was "locked"?

```

4. 

```
Wallet #1 (person who "locks" the number) still lost 1 ADA in this situation, where does that money go? Does it stay in the contract forever? (It's possible to use triggers, but that is still up to the programmer to do, which is suboptimal)

```

Thank you for your time!  
I have also posted a similar post on [reddit](https://www.reddit.com/r/cardano/comments/jnyte4/interesting_case_in_game_example_on_plutus/) if anyone is interested

---

<div class="post-metadata">

**Author:** ![denisonluz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/denisonluz/32/25556_2.png) [@denisonluz](https://forum.cardano.org/u/denisonluz)\
**Post date:** [22 February 2021 00:28 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907/2 "2021-02-22T00:28:59Z")

</div>

@Phantom_of_the_Opera  
I believe the Game source code has been updated, I will try to answer some of these questions based on the new Game version and what I have been learning about Plutus and smart contracts:

_ **What if a player only “knew” about the game after it was “locked”?** _

Someone needs to start the game and lock the guessing number, in this case is the _“Wallet 1”_.  
But if anyone wants to participate in the game later on, it is possible to set a deadline in the future so anyone can join the game and play before that date.

So even though the number was already locked, as long your wallet has access to the “guess” endpoint and the deadline hasn’t passed you still can join and play the game.

The other questions seems to be related to old source code. Please take a look at the name code and let me know if I can help.

---

<div class="post-metadata">

**Author:** ![denisonluz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/denisonluz/32/25556_2.png) [@denisonluz](https://forum.cardano.org/u/denisonluz)\
**Post date:** [22 February 2021 00:35 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907/3 "2021-02-22T00:35:44Z")

</div>

@Phantom_of_the_Opera Please take a look at this answer I found at StackOverflow:

“When the emulator was implemented, there was no specification of the wallet capabilities that Plutus contracts can expect - in fact, one of the motivations for building the emulator was to help us write the specification. _**And it’s quite likely that the current, restrictive interface (forward-looking queries only) will be replaced by something more powerful so that the `startGame` endpoint won’t be necessary anymore.**_”

> <https://stackoverflow.com/questions/57834521/why-do-we-need-startwatching-function-from-walletapi/57855355#57855355>

---

<div class="post-metadata">

**Author:** ![Phantom\_of\_the\_Opera](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/phantom_of_the_opera/32/23036_2.png) [@Phantom\_of\_the\_Opera](https://forum.cardano.org/u/Phantom_of_the_Opera)\
**Post date:** [22 February 2021 16:45 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907/4 "2021-02-22T16:45:34Z")

</div>

Yes, in the newer version `startGame` is not necessary anymore.

(Regarding the lock situation)  
I understand that there are workarounds, nevertheless programmers will eventually forget to include these clauses specially for circunstances where the logic is more elaborate and that can cause losses of ADA which is not desirable and it’s a vulnerability of the programming language.

---

<div class="post-metadata">

**Author:** ![Phantom\_of\_the\_Opera](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/phantom_of_the_opera/32/23036_2.png) [@Phantom\_of\_the\_Opera](https://forum.cardano.org/u/Phantom_of_the_Opera)\
**Post date:** [22 February 2021 16:46 UTC](https://forum.cardano.org/t/interesting-case-regarding-fund-collecting-in-guessing-game-on-plutus/41907/5 "2021-02-22T16:46:32Z")

</div>

Thanks for sharing 🙂
