Go to file
Oskar Thoren 79c678da2e
JSONify balance resp
2021-02-24 12:20:35 +08:00
contracts Revert "Debug contract" 2021-02-05 19:15:25 +08:00
scripts Parameterize swap address 2021-02-09 12:02:23 +08:00
src comment out stdout log 2021-02-09 12:44:52 +08:00
test Init sample hardhat project 2021-01-28 11:27:27 +08:00
.gitignore Init sample hardhat project 2021-01-28 11:27:27 +08:00
README.md Add example task for balance with arg to STDOUT 2021-02-05 19:57:38 +08:00
hardhat.config.js JSONify balance resp 2021-02-24 12:20:35 +08:00
package-lock.json Change web3 version to get rid of random warnings 2021-02-08 12:39:42 +08:00
package.json Change web3 version to get rid of random warnings 2021-02-08 12:39:42 +08:00
pwd.nim pwd nim shell script example use stdout 2021-02-06 13:47:02 +08:00
swap.nim Use Nim script to get balance with hardhat task 2021-02-06 13:50:33 +08:00

README.md

Minimal Swap PoC

A minimal end to end proof of concept of using Swap contracts written by Swarm and maintained here: https://github.com/ethersphere/swap-swear-and-swindle

All contract code imported from the above repo.

Ported to Hardhat and Ethers.io.

How to run

For scripts there is a script to setup SWAP contracts. To run it and make it persistent we can do the following:

# Run a node
npx hardhat node

# Run script to setup SWAP contracts on local hardhat node
npx hardhat run scripts/setup-swap.js --network localhost

Which will return you a list a list of addresses for ERC20, Alice, Bob, and their respective SWAP contracts. You can then interact with it by running a console:

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:
npx hardhat run scripts/sign-cheque.js --network localhost
  1. Copy paste resulting signature and aliceSwapAddress into redeem-cheque.js, and run:
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.

Example task

npx hardhat balance --account 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266