'How do I develop an auto-staker for an NFT game with solidity?

I'm relatively new to solidity development and coding in general, but I'd really like to try and write a program that stakes and un-stakes an NFT after 24 hours.

Some background:

I'm really into the Crypto Unicorns NFT pet collecting game right now, and there's a mini game called the "Dark Forest." The idea behind the Dark Forest mini game is pretty simple: you send your Unicorn NFT into the Dark Forest (by staking the unicorn NFT), and then after 24 hours, your unicorn comes back with items. The only thing is, you have to manually un-stake your unicorn to receive rewards, and then if you wanted to send your unicorn back in the Dark Forest a second time, you would have to do that manually as well.

Is there a way I could automate this process (un-staking, and then re-staking the unicorn NFT after 24 hours) and create some sort of "auto-staker" using solidity? Or would this automation be better handled by some other language like python or java?

Any guidance here would be awesome, as I don't really know where to start. Guidance is especially needed regarding testing the program, since I don't actually own a unicorn NFT. I'm mainly just trying to develop this quality of life program for broader Crypto Unicorns community.



Solution 1:[1]

Smart Contracts cant automate other Smart Contracts which is why we need central servers to do it for us.

Solutions

  • Use OpenZeppelin Defender - Smart Contract Automation UI
  • Use a node provider and create a script that listens to the stake contracts events to automate the process :>

Here is a blockchain node provider use-case code implementation github :>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mnkhod