- Truffle Quick Start Guide
- Nikhil Bhaskar
- 413字
- 2021-06-25 20:47:33
Let's build a to-do list
Productivity is a virtue that resonates a lot with software engineers and developers alike. In the book Algorithms to Live By, Brian Christian states that:
"When the future is foggy, it turns out you don't need a calendar—just a to-do list."
Many of us have come to know that a to-do list helps to organize chaos.
So, let's create a to-do list, except with a little twist. This will be a to-do list on the blockchain, where you get others to do your work for you. Of course, you have to pay them with a token, call it TodoCoin, for their work.
You will create this app as the owner of the contract, and the inpiduals performing your tasks will be referred to as doers.
As an owner, you must be able to:
- Create a task with a title, description, and TodoCoin reward amount
- Accept a completed task
- Reject a completed task
- Reward a doer for successful review of a completed task
As a doer, you must be able to:
- Start a task
- Finish a task
- Withdraw owed rewards for successful reviews of completed tasks
If this seems like a handful, worry not. You will not build all specifications of this Dapp in this chapter. For this chapter, as promised, you will build a simplified version of this Dapp. Later, see if you can slowly start building the other specifications on your own.
For this chapter, you will simply do the following:
- Allow an owner to create the contract
- Allow an owner to transfer a TodoCoin reward to a specified address
That's it. You will assume three things:
- The task has been successfully completed and reviewed off-chain
- The recipient of the reward is a valid doer
- The reward amount is the correct amount for the task
Also, a decentralized application is not complete without a decent user interface. So, you will build a simple interface that allows the owner of a contract to enter a TodoCoin reward amount and transfer it to an address of their choice.
The final version will look like this:
What frameworks will we be using?
The only framework you will use for this chapter is Truffle, actually. This way, you can focus purely on the Truffle elements of this mini Dapp without getting muddled in implementation details of other frameworks. But don't worry, in later chapters, you will learn how to integrate Truffle with Angular, React, and Node.