gradient-onwhite-1 gradient-onwhite-2

SafeEscrow
Technical Specs

This page provides detailed information about our SafeEscrow contract. It's intended for those who are familiar with smart contracts in Solidity. If you're looking for a beginner's guide on how to use SafeEscrow, please check out our "What is SafeEscrow?" guide instead.
The version of SafeEscrow live on this site, SafeEscrow-v-2023-06-15 comprises of two smart contracts on Polygon, SellerDepositedTransactions ("SDT" or "Deposit" transactions), and VerifiedTransactions ("VT" or "Verified" transactions). Both versions of SafeEscrow work as follows:
credit-card

1. Deposit

Buyer deposits payment P into the SafeEscrow contract

crypto-wallet

2. Confirm

The buyer receives the gift card, and checks or uses it to ensure it is good.

crypto-wallet

3. Release

The buyer then forward the payment P onto the seller.

gradient-oncolor-1 gradient-oncolor-2

Paying with USDC via SafeEscrow

We use the Polygon mainnet blockchain to automate buyer protection and give buyers a sense of security when they purchase an item using our SafeEscrow contract. View the official verified source code:
SDT Smart Contract VT Smart Contract
Verified Transactions

In Verified Transactions, the WaterMelonMarkets ("WMM") admin manually verifies that a gift card is valid by collecting the gift card information from the Seller and then going to the official Brand page to verify the card before listing the card on WMM.

The breakdown of major steps is as follows.

  1. The Seller lists the egift card by providing the Full Redemption Info (all the numbers, PINs, expiration dates, etc sufficient to use the egift card) privately to the Website (here WMM).
  2. A WMM Service Admin manually verifies the Full Redemption Info by independently going to the Brand's website and typing that information in. For egift cards that are successfully verified, these cards become visible on WMM.
  3. The Buyer calls VT.createVerifiedTransaction() whereby they deposit the selling price of the egift card into the VT smart contract.
  4. The transactionID, seller, and productPrice is automatically set by the WMM site to match the listing (a requirement for the transaction to be considered valid for that egift card).
  5. The escrowAgent must be an allowed agent, which at this point would the WMM site itself. In the future, support can be expanded to include third-party escrow agents, and even zero-address (which would result in no escrow agent, or "mutually assured destruction (MAD)" if buyer and seller don't agree).
  6. The WMM site at this point verifies the on-chain transaction as valid, and will immediately (within minutes) email the egift card Full Redemption Info to the buyer, as well as providing the info to the Buyer on the WMM transactions page.
  7. The Buyer then can manually themselves verify this information on the Brand website. Ideally the Buyer even uses the egift card within 24 hours of receipt. (Since delivery of VTs are quick, the Buyer can even time the purchase to right before they need to use the egfit card). In an ideal case, the egift card works for the Buyer, and then:
  8. The Buyer forwards the funds using the VT.buyerForwardFunds() function. This allows the Seller to withdraw the funds using VT.sellerWithdraw(). This finishes the transaction successfully!
Off Equilibrium Cases

There are a number of possible non-ideal cases and resolutions afforded by the Verified Transaction system:

  • Suppose the egift card is good, but the Buyer simply forgets to forward the funds. Then the funds are automatically released after a default 14-day timeout period, after which the Seller can run VT.sellerWithdraw() to get the funds.
  • The Buyer can manually run VT.buyerLockFunds() to prevent automatic release from ever happening. The Buyer can undo this move with VT.buyerUnlockFunds().
  • Suppose the egift card is not good and the Seller agrees. The Buyer can message the Seller (through [email protected] if needed) and then the Seller can run VT.sellerRefundEngagedTransaction(), finishing the transaction.
  • Suppose the Buyer does not think the egift card is good, but the Seller does think the egift card is good. Then they can choose to appeal the transaction to the Escrow agent, right now WMM, by emailing [email protected]. The Escrow agent will collect evidence from both sides, and then use the agent's own judgment to decide what fraction of the funds should go to the Buyer, Seller, or be reserved as an Escrow agent fee. Some common results are:

Escrow agent refund
the Escrow agent determines that the Buyer is more likely correct, and issues a full refund to the Buyer.

Escrow agent forward
the Escrow agent determines that the Seller is more likely correct, and forwards the full payment to the Seller.
Deposited Transactions

In Deposited Transactions, the Seller does not provide Full Redemption Info to WMM ahead of time. Instead the Seller puts down a small deposit (currently 1% of price) to guarantee that they will deliver a good product if the product sells.

The Transaction proceeds as follows:

  1. The Seller starts the Transaction on chain by running SDT.createDepositedTransaction(). Here the Seller must specify the product they are selling, the price, and the Escrow agent (currently must be WMM). The Seller must at this time deposit 1% of the price as a SellerDeposit.
  2. The Transaction is now onchain, but to be listed by the WMM public site, WMM admins must first review the listing to ensure it's an allowable product. Once that is done, the product is visible on WMM.
  3. A Buyer comes along, likes the product, and decides to buy it by running SDT.engageDepositedTransaction().
  4. The Seller receives a notice of this, and by default (unless posted otherwise in the listing) has 24 hours to manually send the Buyer the Full Redemption Information through WMM.
  5. The Buyer then verifies this information on the Brand's official page, or ideally by even using the gift card within 24 hours of receiving it.
  6. After confirming the egift card is good, the Buyer forwards on the funds using SDT.buyerForwardFunds().
  7. The Seller then collects the funds using SDT.sellerWithdraw().
Off Equilibrium Cases

There are a number of possible non-ideal cases and resolutions afforded by the Seller Deposited Transactions system:

  • Suppose the egift card is good, but the Buyer simply forgets to forward the funds.  Then the funds are automatically released after a default 14-day timeout period, after which the Seller can run SDT.sellerWithdraw() to get the funds.
  • Suppose the egift card is not good and the Seller agrees. The Buyer can message the Seller (through [email protected] if needed) and then the Seller can run SDT.sellerRefundEngagedTransaction(), finishing the transaction.
  • Suppose the Buyer does not think the egift card is good, but the Seller does think the egift card is good. Then they can choose to appeal the transaction to the Escrow agent, right now WMM, by emailing [email protected]. The Escrow agent will collect evidence from both sides, and then use the agents own judgement to decide what fraction of the funds should to the Buyer, Seller, or be reserved as a Escrow agent fee. Some common results are:
    • Escrow agent refund: the Escrow agent determines that the Buyer is more likely correct, and issues a full refund to the Buyer.  The Buyer may also get a portion of the Seller's Deposit at the beginning, especially if the Seller is nonresponsive after a sale.
    • Escrow agent forward: the Escrow agent determines that the Seller is more likely correct, and forwards the full payment to the Seller.  The Seller would likely keep his Deposit in this case.
    • Unable to decide: the Escrow agent decides the agent has no clear evidence one way or another, and therefore does not adjudicate the case.  The funds are stuck indefinitely unless either the Buyer or Seller relents.
  • Note in the Deposit system, for successful transactions (where the Buyer forwards manually or automatically), the Seller receives the deposit.  In a refund case or Escrow agent deciding case, the Seller does not generally receive their deposit back.  The Deposit is an expression by the Seller that they believe the transaction will complete successfully, which is a cost of listing an item without revealing the Full Redemption Info.
Escrow Agent

As of WMM2.0's launch, all the transactions contain an escrow agent. The escrow agent is chosen by the Buyer or Seller, and in theory can be chosen to be the zero address (no escrow agent; funds are stuck if buyer and seller do not agree). By default for WMM2.0's launch, the escrow agent will be the WMM Agent, an Escrow agent affiliated with WMM. An Escrow agent has substantial power, delegated to it by the Buyer and Seller. Namely, the Escrow agent can end the transaction at nearly any time, splitting the amount of money deposited in the contract between the Buyer, Seller, and the agent (as a fee) any way the Agent sees fit. Currently, the WMM agent is not taking any fees. The WMM will also operate by the following general guidelines.

WMM Agent Behavior

When the WMM Agent is appointed by the Buyer and Seller as the escrow agent, the WMM Agent will not take any fees. The WMM's general steps will be as follows:

Grace Period:
Ensure sufficient time for delivery. The WMM Agent will first wait to ensure that the Seller has had sufficient time to deliver the product, generally set as the normal delivery time + 7 calendar days. By way of example, if a seller originally had 1 day from the purchase time to deliver the gift card, and the Buyer bought the gift card on Monday January 10th at 11AM ET, the WMM Agent will allow the Grace Period to pass, until Tuesday January 18th, 11AM ET, before engaging the case.

Mediated Buyer-Seller Discussion:
After the Grace Period passes, if the dispute is still unresolved, the WMM Agent will begin a Discussion Period of 7 calendar days. Here the Buyer will communicate to both the Buyer and WMM Agent what occurred and what failed to occur to satisfy the Buyer's purchase. The Buyer will ask to have a chance to make a demand of the Seller to fulfill the order. Likewise, the Seller will communicate with the Buyer and WMM Agent about what occurred, and what the Seller would like to see.

Evidence Submission Period:
After the Discussion Period ends, the Evidence Period of 7 days occurs. During this period, the WMM Agent will ask both the Buyer and Seller to submit the best evidence for their cases that they can. The Agent may ask for clarification, but will be more favorable for each side to be comprehensive the first time around.

Decision:
The WMM Agent will make a decision on the split of funds and then execute it. This terminates the transaction. The WMM Agent will use their best judgment in each case, but factors the agent will consider, in rough order of importance are:
  • Strength of Evidence: Which side has better evidence that either a good egift card was delivered or not?
  • Responsiveness / Attention to Detail: Which side provided more evidence and more detailed evidence? Which side responded within requested deadlines?
  • Reputation: If one side has successfully conducted 100 transactions, while the other side is new, this is an important factor.
  • All Else Equal: Slight favor for the buyer. If all the factors above are exactly equal, like many stores, our WMM Agents will favor buyers, giving buyers protection.

Two Layers of Buyer Protection

The SafeEscrow system gives two layers of protection to both the Seller and Buyer.

The first layer is simply having an escrow at all. Buyers are protected because generally the Seller doesn't get funds until after the Buyer gets the egift card and then decides to release the funds. This lets the Buyer verify the cards themselves first. This also reduces Seller fraud in equilibrium because any Seller attempting such knows they are unlikely to get the funds. Likewise, Sellers are protected knowing that the gift card Full Redemption Info is only released to serious Buyers who need to put up funds first.

The second layer of protection for the Buyer depends on the system. For the Verified system, the protection is that WMM has manually verified the Full Redemption Info, ensuring it's a serious Seller with an actually valid card. For the Deposited System, the protection is the Seller's Deposit, which the Buyer may receive a portion of for a bad product.

Closing Thoughts

By using smart contracts and blockchain technology, we are able to reduce the costs of dispute resolution and provide you the customer with lower prices.