Im a little bit confused about how smart contracts work. Let's say there was a contract that users could send ether to in order to play a game. This contract would store the ether sent to it, run the game logic, and handle the funds accordingly.

If the game is finished (let's say each round in the game was active for x amount of hours and x hours have passed), can this smart contract be re-used? Or does a new instance of it need to be deployed again in order for a new round to occur. If it is reused, does it need to be programmed to clear up any old data from the previous round?

2 Answers 2


The solution to your problem can be to use a library.

Your gamming logic will be in a separate library, and your game instance will be in another contract. The game instance contract will make calls to the library to implement the game logic and store the game data in the instance contract. At the end of the game you can call selfdestruct the remove game instance from the blockchain.

You should have a game manager that can create/remove game instances. With this approach more than one game can be running at the same time without interfering with each other.


A contract once deployed to the blockchain, it will stay there forever. You can disable the interaction with it, but you can't completely remove/replace it from the blockchain. Reusability may depend on the logic that it contains.

If it is reused, does it need to be programmed to clear up any old data from the previous round?

Solidity is a Turing complete language. Whatever logic you want, you can put in a smart contract. You can remove the last details, you can store them or you can create a new instance of the smart contract. Lots of possibilities are there, explore the things and let me know if need to know anything more.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.