I am a crypto investor. I am staking a coin but the smart contract requires the user to claim and restake the rewards by transacting a smart contract function every 24 hours. Currently I am doing it manually, which is wasting time. To my understanding, I can just write a program to call this smart contract function to claim and restake automatically. I am already doing similar things to fetch on-chain values (read contract) from Ethereum using Python, web3py, and that program was deployed to the cloud as a Docker container app. However if I want to do something that changes the state (write contract), I will need to provide the private key in order to sign the transaction. This raises a security concern because I am not sure about the best practice on how to store the private key securely.
I have the following proposals:
- I can use a cloud instance, e.g. AWS EC2 and run my Python code there. I can use a .env file to store the private key and inject the private key only during runtime as an environment variable. Or I should totally avoid saving the private key to disk, and instead, just export the key as an environment variable via SSH shell. However, I doubt that even if the code is dockerized, maybe the private key is still accessible to AWS’s staff, and therefore still not secure?
- Another approach is, I can use a Raspberry Pi which will be online 24/7 running scheduled cron jobs using my home network. But the only worry is the network downtime. Also, If the Raspberry Pi is connected to the Internet, I still hesitate to just save the private key as a plain text .env file even on an encrypted SD card. How should I encrypt that plain text secret file and make it accessible only to just one container?
Anyway, can you think of a better solution to this task? Or maybe I’d better ask, in general, what is the best practice to store the secrets if your container app needs to constantly sign digital signatures but at the same time it needs to be run on the cloud?
Pls help. Thx.