Feasibility of smart contract idea: Randomized payout when sending funds

Hello!

I’m watching the Plutus pioneers videos and have some q’s on feasibility of what’s possible. Would love some feedback on how some of this might be implemented or if it isn’t possible:

I’d like to create a contract which behaves like this:

  1. Anyone can send funds to an address
  2. Whenever the address receives funds, a random number is generated, and if the random number is below a certain threshold (say 1 out of 1000 times) the amount of funds in the address is sent back to the person who made the tx.

So some more specific q’s:

  • Can you trigger a contract by simply sending funds to an address? Or do you have to call a function within the contract similar to what’s in the #2 Plutus pioneers video with the “give” function
  • How do you generate random numbers in a contract? I’ve read a bit on other smart contracts and it seems you might need an oracle to do this… how would this work in a Plutus contract?
  • Assuming #1, can you have a contract send back funds to the change address (is that the right term?) of someone who sends funds to a script?

Thanks!

2 Likes