|
1 | 1 | # Zoe Overview
|
2 | 2 |
|
3 |
| -## What is Zoe? |
| 3 | +The Zoe service and smart contract API support credibly trading assets with reduced risk. |
4 | 4 |
|
5 |
| -Zoe is the heart of Agoric's smart contract framework. Use Zoe to: |
6 |
| - |
7 |
| -- **Run your code on-chain** |
8 |
| -- **Mint new digital assets** |
9 |
| -- **Credibly trade assets** |
10 |
| - |
11 |
| -## Why Use Zoe? |
12 |
| - |
13 |
| -- **Zoe is Safer for Users:** A Zoe offer guarantees that you get either |
14 |
| - what you wanted or a full refund of the assets you put in, |
| 5 | +- **Zoe is Safer for Users:** Zoe guarantees that when you make an offer, you get either |
| 6 | + what you said you wanted or a full refund of the assets you put in, |
15 | 7 | even if the contract is buggy or malicious.
|
16 | 8 |
|
17 |
| -- **Zoe is Safer for Developers** For a given offer, if you |
| 9 | +- **Zoe is Safer for Developers**: For a given offer, if you |
18 | 10 | make a mistake with the amount of assets you take or give,
|
19 | 11 | Zoe guarantees that your users will either get what they say
|
20 | 12 | they wanted or get a refund.
|
21 | 13 |
|
| 14 | +## High Level Trading Flow |
| 15 | + |
| 16 | +Trading with a contract using Zoe typically goes through these steps: |
| 17 | + |
| 18 | +<img src="./assets/offer-safety-flow.svg" alt="offer safety flow with contracts, zoe, and parties" |
| 19 | + style="border: 2px solid" /> |
| 20 | + |
| 21 | +1. Parties call [E(zoe).offer(invitation, proposal, assets)](/reference/zoe-api/zoe#e-zoe-offer-invitation-proposal-paymentpkeywordrecord-offerargs). Zoe escrows the assets. |
| 22 | +2. Zoe relays the proposal to the contract identified in the invitation. |
| 23 | +3. The contract handles proposals using its custom business logic. |
| 24 | +4. The contract instructs Zoe to [reallocate](/reference/zoe-api/zoe-contract-facet#zcf-reallocate-seats) assets among the parties. |
| 25 | +5. The contract completes (aka [exits](/reference/zoe-api/zcfseat#azcfseat-exit-completion)) the offers. |
| 26 | +6. Zoe pays out assets to the parties. |
| 27 | + |
| 28 | +Note that in this flow, _assets are not sent to the contract_; only information about them. _For more on this distinction, see [The Settlers of Blockchain](https://agoric.com/blog/technology/the-settlers-of-blockchain) Jun 2021._ |
| 29 | + |
| 30 | +::: tip Watch: Offer Safety: Partitioning Risk in Smart Contracts (20 min. Sep 2019) |
| 31 | + |
| 32 | +<iframe width="400" height="225" src="https://www.youtube.com/embed/T6h6TMuVHKQ?si=NzWre0vhlxjBxG-5&controls=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> |
| 33 | + |
| 34 | +::: |
| 35 | + |
22 | 36 | ## Bundling a Contract
|
23 | 37 |
|
24 | 38 | In [deploying the basic dapp contract](../getting-started/#starting-the-dapp-smart-contract),
|
@@ -292,7 +306,11 @@ and tests that it's what she wanted.
|
292 | 306 |
|
293 | 307 | <<< @/../snippets/zoe/contracts/alice-trade.js#payouts
|
294 | 308 |
|
295 |
| -## Example Contracts |
| 309 | +## Live Coding and Example Contracts |
| 310 | + |
| 311 | +::: tip Watch: How To Build a Composable DeFi Contract (1:47 Dec 2020) |
| 312 | + |
| 313 | +<iframe width="560" height="315" src="https://www.youtube.com/embed/e9dMkC2oFh8?si=3Luwp25R8d23elAa" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe> |
296 | 314 |
|
297 | 315 | Agoric has written [a number of example contracts that you can
|
298 | 316 | use](./contracts/index), including:
|
|
0 commit comments