Inspiration
Crypto wallets are notorious for the issues caused by their irrecoverability. However, these problems are not exclusive to people that lose their private key or mnemonic; wallets owned by people who have passed away are also subject to an unproductive loss of funds. We want to solve this without forcing wallet users to provide someone with their private key/mnemonic. Thus, we have created a will protocol that releases funds upon the will creator's death.
What it does
A user first connects their wallet to our protocol. Then, they set an amount of Luna/UST that they would like to place in their will, it is up to them to make sure that amount of the native token is available in their wallet. The user then adds beneficiary's public Terra Station wallet addresses, along with a percentage of will tokens the beneficiary will receive. A will can then be created contingent upon i) the amount of native token being placed in the will is greater than 0, ii) there is at least one beneficiary, and iii) the sum of each beneficiary's percent allotted funds must be 100. A will creator can modify their beneficiaries and the amount of funds in the will at any time. If funds or beneficiaries are set to zero, the will is deleted.
In the future, individual deaths will be easy to query through an oracle. We think that this may also be possible today; for example, when an individual dies their bank account is frozen, assets are distributed, and the account is shut down. We could get access to this information and use it as proof of death. However, for this project, we put the burden of proof of life on the user. A will creator must interact with their will at least once every 365 days, or else their beneficiaries can request their fund allotment. Our website has a 'Renew Will' tab which shows a 365 day countdown to the user that will be reset to 365 days when the user clicks the 'renew' button. Also, any time the user modifies their will, the countdown is also reset.
How we built it
On the backend we used a single smart, contract.rs, located in the src of our will folder. The contract initializes will structs ( recipient address, timestamp, assets), which are stored in a HashMap as a value with the will creator's address as the key. This HashMap is stored as a field in our contract, rather than creating a willFactory contract and many Will contracts. We used a Javascript React app on frontend, and made use of Terra js to bridge the two.
Challenges we ran into
Our biggest challenge was figuring out how to send assets between our contract address and individual Terra Station addresses. This was due to a lack of documentation and the difficulty of dealing with submessages, cosmosmessages, terra js, and the myriad complications that came with connecting the different components necessary. another challenge we faced was figuring out how to work with cosmwasm, terrain, and using rust on terra. For example, we ended up having to download a newer version of terrain than that available in the setup documentation
npm install -g @terra-money/terrain
We also figured out that error 400 upon contract deployment is not a 'real' error; it just means info query is being rejected as the block is not done being created/written to.
Accomplishments that we're proud of
We are extremely happy that we managed to get our token transactions working between wallets and our smart contract! Also, our solution to the 'death oracle problem' is very feasible while we wait for a better oracle solution to be implemented, free of user burden. Finally, our frontend is fire and we are very happy with how it turned out! Peep the sliders + pie chart though....
What we learned
We learned soooo much, not only about the Terra ecosystem, but about defi in general. Working with the constraints of the blockchain to, for example, implement time-sensitive functionality in our protocol helped us understand the types of projects that are defi-compatible. Coding in rust was also a good (though painful) learning experience.
What's next for Legacy Protocol
We have a solid roadmap for Legacy moving forward. Firstly, we would like to implement added functionalities like staking of funds being held in the will contract for will owners. Secondly, we believe the idea behind Legacy Protocol is highly generalizable and is especially relevant to the legal field. Seeing that wills are generally a legal matter that necessarily involve a legal entity (that has to be paid), we believe Legacy Protocol demonstrates that many routine legal actions (document notarization, jail bonding, etc.) are an easy first step towards implementing blockchain day-to-day. Finally, we would also like to figure out a better oracle mechanism, and think this will be possible in the near future as information becomes increasingly digitized.
This project turned into Bequest.com!
Built With
- cosmo
- javascript
- material-ui
- react
- rust
- terra
- terra-station
- terrain
Log in or sign up for Devpost to join the conversation.