So one project I am working on and am pretty confident in getting a group of ladies in my community to test out is creating an RSVP dapp. Imagine the everyday scenario, you and Joey Wheeler met up with each other, you two have both said numerous times that you two would get together to catch up over a drink. Finally you guys commit to setting up and agreeing to a clear meetup; Slifer’s Skyride; Bar and Grill at 6PM for the last of Happy Hour. It has a nice view and is surprisingly convenient to reach and not out of your way on your daily grind. So you make it to the venue just on time to enjoy the final hour. One hour later, you have finished enjoying the final hour.
Alone.
Not even a response back.
ENTER: RSVP dapp.
Put your money where your mouth is! Set up a smart contract where you agree on the time and location, and how much ETH to put as collateral. If your counterparty member is serious, he’ll stake that ETH. He’ll get it right back if he makes it on time. Late, he receives a penalty. Doesn’t show up, the ETH is forfeited to you. But here’s the kicker, you just created a transaction where you profited off of something that wasn’t meant to happen. Thus creates the following dilemma, what do you do with it? You can
A) Give it back
B) Pay for your meal
C) PUT IT IN POOLTOGETHER
Should this project be built out to reach the phone, we’ve just created a simple trojan horse to expose the masses to DeFi; solving a major problem while using a lossless DeFi protocol for a very very safe crypto experience. I’ll link my excalidraw sketches for concept I’m building out.
The current biggest obstacle I foresee with this app is this; if I’m Joey Wheeler, if I have a major problem in being on time, why would I want to download this and lose money?
To this question, it looks like I may have leverage a social layer, SHAME to pressure people to upholds others to a higher standard and keep each other accountable. That’s all I got as I build this project out. Any thoughts?
I submitted this for Chainlink’s hackathon that took place during the month of February and finished on March 8th.
I am posting an archived link because they use the same url for each of their hackathons so (to my knowledge) there’s no official Hackathon site archive.
And my repository
I have some bitter feelings regarding the project thus far. First, Chainlink’s CRE, “Chainlink Runtime Environment”, was not at at all easy for me to learn. And I had a tough time conceptualizing where it fit into the grand scheme of the project. Having reached some sort of build, I think I can best describe CRE as an orchestrator to interface with offchain systems to coordinate with smart contracts on the blockchain, handle computations or validations or general data processing off chain, leading to far more complex decentralized applications. This is a mouthful and seems like a word salad so I’ll apply it to my project.
Within the context of my version 0.001 build here, the entities and components of my build were:
A dummy API for location data
User A, Let’s call him Ed
User B, Let’s call him Bo
Blockchain contracts: RSVP contract and Mock Pool Together
CRE
I combined the contracts together because once you are onchain, it’s easy to talk to one another on chain. But let’s discuss the workflow of the project. I’ll bold the entities above when they take action. And there is a further assumption that Ed and Bo also communicate with each other through a phone (remember, this is a social contract for everyday use).
Ed distrusts Bo and decides to use the app to set up a rendezvous, (a fitting name now that I realize it since the meeting location is encrypted but posted on the blockchain). Within the context of the contract, the rendezvous is represented as a struct Rendezvous with a bunch of parameters that are filled as the conditions are met leading up to the event and Ed initiates using the proposeRSVPfunction.
Ed calls CRE to do an encrypted HTTP Request from the API where CRE would pull the location data (location coordinates and timestamp and some other information), encrypt it, and post it onchain to store into a variable
I admit and am embarrassed to say I didn’t figure this out but I ended up copypasting the content into the parameter for the setRendezvousLocationAndPostsCollateral function. Here Ed would first approve the collateral for USDC (this is the innate ERC-20 function he has to manually approve) he intends to put up and then use the setRendezvousLocationAndPostsCollateral function to post the encrypted data and send the USDC to the contract.
/////// Quick note: ////////
My issue on why I didn’t have CRE send the the encrypted data into a function outright to avoid an obvious manipulation exploit is because I couldn’t figure out how to get past a requirement I put in my function that expects the msg.sender to be the Rendezvous proposer. The sender showing up would be CRE’s forwarder address, the contract on the blockchain that receives the data from the decentralized oracle network that processes my CRE request.
If I were to do things differently (I’ve proverbially bashed my head against the wall for figuring this out a couple days after I submitted the project) I would create a mapping (address user => string requestedData) that CRE would call a function to fill it with the relevant data. But at the point in time I worked on 3), I didn’t know how to call functions, nor did I know how to have CRE differentiate between calling a function or storing data. And as I progressed through the project, I didn’t look back and left bugs as is.
////////// Rant completed /////////
Ed would send the relevant decryption key and nonce to Bo to decrypt the location proposed in the contract off chain on some other communication system. In this build, Bo would also have to go on this cypher tools site to use the provided info to decrypt… and then he’d need yet another tool to translate the geolocation coordinates to match the visible location to.
Bo would then have to approve the required amount of USDC and then call the acceptOrDenyRendezvous function to accept or deny the meeting.
//quicker note:
The current iteration presents a denial of service bug because I allowed Bo to use any address instead Ed approving the address. I’m not sure how I’ll proceed forward with this, either figuring out how give Bo freedom to choose which address to use without Ed’s approval or Ed needing to whitelist an address first.
Within 15 minutes of the Rendezvous time (it’s currently hardcoded to 20 minutes from when proposeRSVP was called), either Bo or Ed can call checkIn. For the demo, I called CRE to post an encrypted request data payload to chain and then… copypasted again.
// quicker note:
And here is where my idea for a mapping (address user => string requestdata) should evolve to a mapping (address user => string[2] requestData) so the second slot should be filled with the checkIn data from CRE.
I call CRE to verify the checkIn. In this case, I "simulated’ a check In, where I isolated the data offchain in my workflow scripts to show I could do it, but I didn’t actually do anything with the data. So CRE computes a true boolean and then calls back to the blockchain to update the Rendezvous struct with a true for the verifyCheckedIn for the respective user.
// quick note
This part gave me insight in how CRE presents essentially a safe space to do data computation. I don’t know if the data computation is visible to the DON since this is where I’d have to decrypt to verify.
I have CRE call settleAggreement to settle the agreement. If both’s checkin were verified, each would get their money back. If someone wasn’t verified by the meeting time, they forfeit their stake. And here is the fun part; the stake gets automatically deposited in a Mock Pool Together pool on behalf of the punctual person!
//////////////////////////////////////
General thoughts
CRE is a really powerful tool, but it’s not easy to use. For production level, I’d like to know how to automate these scripts as each time CRE ran, I manually ran a script. And for the CRE call to verify the check-ins, I needed to pass the transaction hash to trigger it.
The bigger concern is what my data source would be for the location. I used my browser data to pull my location. Ideally this project would be on a phone. So there is a concern of GPS spoofing. The API source would need a signature that would be ingested during the verification for the check In. Something, I’m spitballing here. I was also informed that you could send in a chunk of location pings and the smoothness of the locations sent should test for someone physically being there as opposed to a load of spoofed data.
Felt like writing this up because I had a lot to get off my chest and shouting at the wind is seemingly more therapeutic than keeping it all in my head.
And more importantly, I’m overlooking the realization I had that this is a slick way of introducing people to DeFi. Either you and your counterparty uphold their obligations of being punctual and honoring the timing of your agreement, or someone gets rewarded with a payout with the option of withdrawing it, or leaving it in a protocol (we’re not even going to ask to put it in). I chose Pool Together because it’s a lossless lottery; a safe protocol to expose the masses to. You pool together your money with others into a lending market like Aave for interest accrual. Once per time period, one lucky guy gets the interest accrued. So if a time period is a year and you pool with others $100K in a 10% interest rate market, one lucky guy gets $10K. And they withdraw at any time.
Finally, I want to muse a bit on the transaction, the money used to send to Pool Together. Assuming Ed came on time and Bo failed to do so, Ed received money he should not have, and Bo knows he got punished for not making it on time (I’ll add the ability to waive the right to take the money, to not be so cruel). This may sound morbid, but this unnecessary transaction, this undeserved monetary gain, would be easier to sway out a person’s hand than if he worked all day for it. Thus why I am putting it in Pool Together to expose people to DeFi.
And one more thing, imagine using an app like this with a dinner with a large friend group. Imagine if most of them were always late. Wouldn’t it be nice to have a free meal, huh?