From e512cdd9d9416e50d5af09c4f340a2a90b387433 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sun, 28 Jun 2020 22:40:11 +0200 Subject: [PATCH] Update escrow readme --- contracts/cw20-escrow/README.md | 48 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/contracts/cw20-escrow/README.md b/contracts/cw20-escrow/README.md index 2b8d202f2..295e750df 100644 --- a/contracts/cw20-escrow/README.md +++ b/contracts/cw20-escrow/README.md @@ -1,15 +1,29 @@ -# CW20 Basic +# CW20 Escrow -This is a basic implementation of a cw20 contract. It implements -the [CW20 spec](../../packages/cw20/README.md) and is designed to -be deloyed as is, or imported into other contracts to easily build -cw20-compatible tokens with custom logic. +This is an escrow meta-contract that allows multiple users to +create independent escrows. Each escrow has a sender, recipient, +and arbiter. It also has a unique id (for future calls to reference it) +and an optional timeout. -Implements: +The basic function is the sender creates an escrow with funds. +The arbiter may at any time decide to release the funds to either +the intended recipient or the original sender (but no one else), +and if it passes with optional timeout, anyone can refund the locked +tokens to the original sender. -- [x] CW20 Base -- [ ] Mintable extension -- [ ] Allowances extension +We also add a function called "top_up", which allows anyone to add more +funds to the contract at any time. + +## Token types + +This contract is meant not just to be functional, but also to work as a simple +example of an CW20 "Receiver". And demonstrate how the same calls can be fed +native tokens (via typical `HandleMsg` route), or cw20 tokens (via `Receiver` interface). + +Both `create` and `top_up` can be called directly (with a payload of native tokens), +or from a cw20 contract using the [Receiver Interface](../../packages/cw20/README.md#receiver). +This means we can load the escrow with any number of native or cw20 tokens (or a mix), +allow of which get released when the arbiter decides. ## Running this contract @@ -23,9 +37,9 @@ Once you are happy with the content, you can compile it to wasm via: ``` RUSTFLAGS='-C link-arg=-s' cargo wasm -cp ../../target/wasm32-unknown-unknown/release/cw20_base.wasm . -ls -l cw20_base.wasm -sha256sum cw20_base.wasm +cp ../../target/wasm32-unknown-unknown/release/cw20_escrow.wasm . +ls -l cw20_escrow.wasm +sha256sum cw20_escrow.wasm ``` Or for a production-ready (compressed) build, run the following from the @@ -36,13 +50,5 @@ docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="cosmwasm_plus_cache",target=/code/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ cosmwasm/rust-optimizer:0.8.0 ./contracts/cw20-base -mv contract.wasm cw20_base.wasm +mv contract.wasm cw20_escrow.wasm ``` - -## Importing this contract - -You can also import much of the logic of this contract to build another -ERC20-contract, such as a bonding curve, overiding or extending what you -need. - -**TODO** \ No newline at end of file