From 77e6c79ba3f83c1fba680ef9139c00791f0a8743 Mon Sep 17 00:00:00 2001 From: Oskar Thoren Date: Fri, 5 Feb 2021 19:25:22 +0800 Subject: [PATCH] Update README --- README.md | 18 ++++++++++++++++++ scripts/redeem-cheque.js | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f12660..2c0c004 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,21 @@ Which will return you a list a list of addresses for ERC20, Alice, Bob, and thei ``` sh npx hardhat console --network localhost ``` + +After setting up basic SWAP contracts, we can issue and redeem a cheque. + +TODO: Turn copy-pasting into CLI arguments or automate it + +1. Copy paste the aliceSwapAddress into `sign-cheque.js` script. Then run: + +``` sh +npx hardhat run scripts/sign-cheque.js --network localhost +``` + +2. Copy paste resulting signature and aliceSwapAddress into `redeem-cheque.js`, and run: + +``` sh +npx hardhat run scripts/redeem-cheque.js --network localhost +``` + +Now Alice has send a cheque to Bob, and Bob has received it from the Swap contract. Cheques can be sent and received off-chain, and only settled once Bob wants to. diff --git a/scripts/redeem-cheque.js b/scripts/redeem-cheque.js index 3ad3f98..45310b3 100644 --- a/scripts/redeem-cheque.js +++ b/scripts/redeem-cheque.js @@ -20,12 +20,12 @@ var aliceAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; var bobAddress = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8"; // XXX These change -var erc20address = "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"; +//var erc20address = "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853"; var aliceSwapAddress = "0x94099942864EA81cCF197E9D71ac53310b1468D8"; - // XXX Hardcoded return from sign-cheque script of cheque from Alice to Bob: var issuerSig = "0x67c0c9ec1e72e90ebf0155b10953ec81b1ff5bca6283e51bee9bb55ec2fa14876278e88e8f0a34570bed0f9bed4cec9c576dc0ac34512adddbfd157b5be5df091c"; + // TODO This should be parameterized with arguments, so probably as a task or standalone script? async function main() { var recipient = bobAddress;