One of smart contracts’ main weaknesses is that they cannot self-execute. They always need a caller to call one of their functionalities for a transaction to be generated. This means that if you have a function in your contract you want to call sometime in the future, you will have to call the contract at that time yourself and it cannot be done automatically. In other words, scheduling an asynchronous event on the Blockchain is quite difficult.
Enter Prometheus. Prometheus introduces a class of contracts that can be called asynchronously when a certain state is reached, even if the contract’s owner is not available to change the contract state at that time. Prometheus relies on Ravens – scripts that other Blockchain users can run – to poll the state of a contract, and execute a function asynchronously when criterion are met. In exchange for this execution, the accounts that run the Ravens are paid by the contract owners through a middle-man contract called a Prometh to prevent fraud.
What it does
Each Prometheus has a list of Prometh connected to it, and each Prometh links to an Agent, or a contract someone has written which needs to be called asynchronously in the future. From a Prometheus, people can create new Promeths and attach them to their Agents, assigning a reward and sending funds to the Prometh to transfer to the executor on function execution. A Raven can connect to a Prometheus, and constantly cycle through its list of Promeths to find any whose state is ready for its asynchronous call. In such a scenario, the asynchronous call will be made and a payment will be processed from the Prometh to the Raven owner.
How we built it
Prometheus was built using Solidity with NodeJS and Web3. Truffle was used for compiling and migrating contracts onto testrpc for functionality verifications. Three separate contracts, one each for Prometheuses, Promeths, and Agents, were created to form the overall structure. A contract maker need simply implement the fundamental two Agent methods of checking the contract state and performing the asynchronous execution to be deemed valid and be connectable to a Prometh.
Challenges we ran into
The main challenges we ran into were with creating the web3 scripts, as many of the calls were asynchronous but needed to be executed synchronously. Making the initial Solidity contract was also a good challenge since we had to think thoroughly about the requirements of each of the Prometheus, Prometh, and Agent classes. Even coming up with an idea for the hackathon required lots of iterations, however when the idea of asynchronous contract calling came up, we knew we had a problem worth solving that could help many developers create better contracts.
Accomplishments that we are proud of
Writing code that actually works within a 36 hour period! This was the most productive hackathon we have been a part of, and we are both very proud of our preparation and dedication to finishing the project on time.
What we learned
Keyan learned Solidity and Web3 all throughout this week, so it was an all-at-once crash course experience for him. He feels like he better understands Ethereum and the potential of smart contracts after this hackathon.
Will learned how to integrate web3 into his webpages to help developers more easily create contracts.
What's next for Prometheus
Next steps include but are not limited to: • Cleaning up the codebase • Publishing Prometheus to open-source for other developers to use • Reducing overhead • Focusing more on edge cases • Adding more desired functionalities to the Prometheus, Prometh, and Agent classes