user2080: I'm looking for an example or tutorial for how to write a smart contract which locks all ADA sent to it until a threshold of at least 1,000 ADA is reached. Once 1,000 ADA is reached, as much ADA as possible is sent to a pre-defined address and the counter resets. Is this possible with the current Plutus platform?
Thanks, Myles

user1130: As @George pointed out, there is no such thing as "automatic" for smart contracts. Everything must be triggered manually by an off-chain actor.
That being said, you could definitely create a script that holds funds in escrow until a threshold is reached, at which point those funds become distributable/claimable.
This is similar to how the auction code works:
Each time someone bids, the auction datum is updated. In the case of the auction, once a deadline has been past, the bids are collectable by the seller and the bidder can claim their winnings.
You could follow a similar pattern where a datum tracks the ADA locked at the script address, and the datum is replaced with an updated datum each time more ADA is locked. At the point the locked ADA passes 1000, the funds become claimable.
There are many ways you could organize the distributions, but the simplest/closest to automatic might be as follows: any transaction that pushes the total equal to or over 1000ADA must distribute to the designated recipients, and all excess tokens will be rolled over to a new datum. That makes the last contribution more expensive, so it might discourage contributions, so you could consider paying the distribution fees with the pot or something else.

user5122: I am not sure what you mean by automatically send funds out of smart contracts". If you mean without someone actually executing the contract in a transaction, this is not possible. Just people sending ADA to the smart contract address will not trigger the smart contract execution, someone has to do a transaction including the smart contract execution to do what you want.

2080: <p>I'm looking for an example or tutorial for how to write a smart contract which locks all ADA sent to it until a threshold of at least 1,000 ADA is reached. Once 1,000 ADA is reached, as much ADA as possible is sent to a pre-defined address and the counter resets. Is this possible with the current Plutus platform?</p>
<p>Thanks, Myles</p>
 1130: <p>As @George pointed out, there is no such thing as &quot;automatic&quot; for smart contracts. Everything must be triggered manually by an off-chain actor.</p>
<p>That being said, you could definitely create a script that holds funds in escrow until a threshold is reached, at which point those funds become distributable/claimable.</p>
<p>This is similar to how the <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/8cbc68d146c82cc95d9be44c30e049aba3774003/code/week01/src/Week01/EnglishAuction.hs#L103" rel="nofollow noreferrer">auction code</a> works:</p>
<p>Each time someone bids, the auction datum is updated. In the case of the auction, once a deadline has been past, the bids are collectable by the seller and the bidder can claim their winnings.</p>
<p>You could follow a similar pattern where a datum tracks the ADA locked at the script address, and the datum is replaced with an updated datum each time more ADA is locked. At the point the locked ADA passes 1000, the funds become claimable.</p>
<p>There are many ways you could organize the distributions, but the simplest/closest to automatic might be as follows: any transaction that pushes the total equal to or over 1000ADA must distribute to the designated recipients, and all excess tokens will be rolled over to a new datum. That makes the last contribution more expensive, so it might discourage contributions, so you could consider paying the distribution fees with the pot or something else.</p>
 5122: <p>I am not sure what you mean by automatically send funds out of smart contracts&quot;. If you mean without someone actually executing the contract in a transaction, this is not possible. Just people sending ADA to the smart contract address will not trigger the smart contract execution, someone has to do a transaction including the smart contract execution to do what you want.</p>
