<p>Scripts are executed as part of a transaction validation. That means: no transaction -&gt; no script execution. The blockchain has no mechanism of timed or automatic script execution. What you can do is to implement transaction submission at every new epoch in your off-chain code.</p>

CC BY-SA 4.0
2022-02-15T10:58:00.553Z
2022-02-15T10:58:00.553Z
Jey
<p>As mentioned by Jey earlier, blockchains and smart contracts remain latent until triggered by a user submitted transaction.</p>
<p>One way you could pull this off is that you could use the cardano-cli application to create, sign and submit a transaction which executed the plutus script at the end of every epoch. You can find out more about <a href="https://docs.cardano.org/plutus/Plutus-transactions" rel="nofollow noreferrer">cardano-cli and plutus scripts here</a> and a simple sample <a href="https://github.com/input-output-hk/Alonzo-testnet/blob/main/Alonzo-solutions/exercise3/e3SampleSolution.md" rel="nofollow noreferrer">here</a></p>
<p>UPDATE: I realized that I missed out explaining how this could be done by creating an javascript bot which submits this kind of transaction near the end of the epoch automatically.
You can use the <a href="https://github.com/Berry-Pool/cardanocli-js" rel="nofollow noreferrer">cardanocli-js</a> javascript library to achieve this... here's a <a href="https://developers.cardano.org/docs/get-started/cardanocli-js/" rel="nofollow noreferrer">basic sample</a>, but you can pretty much do any kind of action that the cardano-cli can do, in a programmatic submission.</p>
<p>Hope this helps!</p>

CC BY-SA 4.0
2022-02-16T10:29:01.247Z
This is exactly what I learned at the Plutus Pioneer Program but I just needed to be sure I was understanding it correctly. Thank you very much for your clarification!
Falcon Stakepool
CC BY-SA 4.0
2022-02-15T12:58:53.153Z
2022-02-18T00:11:14.730Z
2022-02-18T00:11:14.730Z
Bharat Mallapur
<p>I would like to develop a Plutus script that executes each time an epoch ends.</p>
<p>What's the best way to achieve this behaviour?</p>

<plutus><smart-contract><script><script-addresses>
Plutus script execution at every end of epoch
# Plutus script execution at every end of epoch

(Asked by: username_0 on 2022-02-15)

I would like to develop a Plutus script that executes each time an epoch ends.

What's the best way to achieve this behaviour?

**Tags:** plutus, smart-contract, script, script-addresses

---

## 2 answers

### Answer by username_2 on 2022-02-15. Score: 3 | Accepted answer

As mentioned by Jey earlier, blockchains and smart contracts remain latent until triggered by a user submitted transaction.

One way you could pull this off is that you could use the cardano-cli application to create, sign and submit a transaction which executed the plutus script at the end of every epoch. You can find out more about [cardano-cli and plutus scripts here](https://docs.cardano.org/plutus/Plutus-transactions) and a simple sample [here](https://github.com/input-output-hk/Alonzo-testnet/blob/main/Alonzo-solutions/exercise3/e3SampleSolution.md)

UPDATE: I realized that I missed out explaining how this could be done by creating an javascript bot which submits this kind of transaction near the end of the epoch automatically.
You can use the [cardanocli-js](https://github.com/Berry-Pool/cardanocli-js) javascript library to achieve this... here's a [basic sample](https://developers.cardano.org/docs/get-started/cardanocli-js/), but you can pretty much do any kind of action that the cardano-cli can do, in a programmatic submission.

Hope this helps!

> **Comments:**
> **username_0**: This is exactly what I learned at the Plutus Pioneer Program but I just needed to be sure I was understanding it correctly. Thank you very much for your clarification!  

---

### Answer by username_1 on 2022-02-15. Score: 1

Scripts are executed as part of a transaction validation. That means: no transaction -> no script execution. The blockchain has no mechanism of timed or automatic script execution. What you can do is to implement transaction submission at every new epoch in your off-chain code.


---

