Nick

How the Tipping Point [Bank Teller] Smart Contract Works

Have you heard of a past startup called CrowdTilt? It was acquired by Airbnb and the idea was crowdfunding for events and only pulling funds from users after a goal threshold was met, like as a goal amount of $1,000 for a spring break beach house party.

Tipping Point is basically a version of that built w/ crypto as the financial rails.

When the “Tipping Point” of a campaign is met, i.e. the $ goal amount is raised, then funds transfer from the invitees to the campaign creator. Simple.

But instead of credit-card processors and banks transferring $USD, we are using the Ethereum blockchain, to automatically transfer the funds (w/ USDC tokens). Well, the Coinbase layer-2 called Base to be exact.

So, how do you transfer crypto-funds at a future date for multiple users in a secure, and trustful manner? Is that natively possible yet on the blockchain? Sorta.

ERC-20 interfaces have one function that allows the spending of another users tokens. That is the approve(spender, amount) function. By calling that function I can approve an allowance for another address to move a certain amount of my tokens, such as a decentralized exchange to swap out 100 of my USDC for another ERC-20 token such as DAI. The problem is that alone gives them indiscriminate spending power to do with they want with it, so a specific Smart Contract address whose code is public and has been audited is typically given the allowance so you can be certain it is used in specified way, i.e. dApps.

We did not make a 100% decentralized app because we wanted the versatility and control of updating features on the app, like a standard web2 app.

Our solution to approves() shortcoming was the BankTeller smart contract.

When you sign a check to pay your rent, you write a $ amount, a date, and a recipient name. The recipient takes your check to the bank, and the bank teller will authorize the validity of the check to transfer funds from your account to the recipient. Using the native features of Solidity and smart contracts we’ve replicated the same flow for Tipping Point so users can authorize a specific amount of USDC to transfer to a creator if an event succeeds(i.e. “Tips”).

How - The Details:

When an invitee opts in we require 2 steps from them.

  1. Approve the USDC allowance for the Bank Teller smart contract to move their funds
  2. Sign a message(an json object called“DestinationApproval”) that acts as an additional authorization for the Bank Teller to move your funds

Once the USDC allowance is executed, we then save the 2nd signature, ”DestinationApproval”, in the DB to only execute when the event has successfully tipped.

Once an event has reached its financial goal, we take all the DestinationApproval signatures for that event and send them to the BankTeller to transfer the funds. But what happens in the Bank Teller Smart Contract when it receives a signed DestinationApproval message?

The contracts transactions and source code can be found on BaseScan: https://basescan.org/address/0x734b54Ab94BaE04972e33e687EBfD46D059EC40f#code

To transfer funds we call the transferInviteeFunds() function on the BankTeller contract and pass in the DestinationApproval object and the signature. The DestinationApproval object is the figurative bank check in the flow. This function is the guardrail that protects the invitee. It does a few things: - Checks the invitee signature against the DestinationApproval is valid - Checks the deadline on the DestinationApproval message has not passed (typically 2 weeks after the campaign deadline) to avoid transferring funds on old campaigns - Checks that the function was only called by the owner of the BankTeller smart contract, a Tipping Point EOA, preventing 3rd parties from triggering it - Checks that the DestinationApproval message has not already been executed, to avoid double spend on a campaign

If all checks pass then the funds transfer according to the authorized details of the DestinationApproval message that the invitee signed: - USDC amount - Creator address - Event id - Deadline Now the trust has been localized to the Bank Teller code and invitees can rest assured their funds transfer to the creator for their exact amount. Simple.