* Minimal Crypto Exchange

** How to start the whole thing  

See [[https://dpisarenko.com/mce/en/how-to-start/][this tutorial]].

** ETH Addresses

*** Buffer

 * Address: ~0x411167FeFecAD12Da17F9063143706C39528aa28~
 * Private Key: ~0x766df34218d5a715018d54789d6383798a1885088d525670802ed8cf152db5b4~
 * Password: ~carsdrivefasterbecausetheyhavebrakes~
    
*** Signer

 * Address: ~0x0c56352F05De44C9b5BA8bcF9BDEc7e654993339~
 * Private key: ~0x0d0b4c455973c883bb0fa584f0078178aa90c571a8f1d40f28d2339f4e757dde~

*** Exchange    

 * Address: ~0x190FD61ED8fE0067f0f09EA992C1BF96209bab66~
 * Private key: ~b07aedf303f832664eb7a5295be737776cb1ad17a277ec287b3b3c7bac154e5e~
 * Password: ~a-turkey-is-a-chicken-designed-by-a-committee~

*** USDT Sender

 * Address: ~0xDd1e8cC92AF9748193459ADDF910E1b96E88154D~
 * Private key: ~620a589aa99ef4944cfd670503959b47f78d1b03d625bc6adf978736745bf30d~
 * Password: ~only-cheese-in-a-mouse-trap-is-cheap~

** Miscellaneous

*** How to generate ETH addresses for the testnet

Use https://vanity-eth.tk    
   
*** How to use Camunda

**** Step 1: Login

Navigate to `http://localhost:8080` and login into the cockpit using ~demo~ as password and username.

**** Step 2: Start a process

Go to the tasklist by clicking on ~Tasklist~ in the dashboard.

[[file:docs/img/2021-10-17_01.png]]
    
Click on the ~Start process~ button.

[[file:docs/img/2021-10-17_02.png]]

Click on one of the processes from the list in the window that appears thereafter.

[[file:docs/img/2021-10-17_03.png]]

Enter any text as business key and press ~OK~.

[[file:docs/img/2021-10-17_04.png]]

**** Step 3: Observe the process in the cockpit

Go back to cockpit by clicking on ~Cockpit~ in the dropdown list next to the home icon:
     
[[file:docs/img/2021-10-17_05.png]]

In dashboard, click on ~Process Definitions~.

[[file:docs/img/2021-10-17_06.png]]

You should see a list like this:

[[file:docs/img/2021-10-17_07.png]]

Click on the process instance ID in the list.

Thereafter you will see the diagram of that process instance.

[[file:docs/img/2021-10-17_08.png]]

Click on ~java.math.BigInteger~. Following window will appear:

[[file:docs/img/2021-10-17_09.png]]

This is the amount of wei in the Ethereum exchange account.

*** How to check the BTC balance

**** Step 1: Open the shell of BTC testnet
     
[[file:docs/img/2021-09-18_01.png]]

**** Step 2: Run the CLI command

In the shell window that appears thereafter, enter ~bitcoin-cli getbalance~.

[[file:docs/img/2021-09-18_02.png]]

*** How to generate a new Bitcoin address

**** Preconditions    

 * BTC testnet shell is open (see step 1 of the section *How to check balance* on how to do this).

**** Process

Run ~bitcoin-cli getnewaddress~ in the BTC testnet shell.

The output will be something like ~2N5Yngd2nDX4pur3Wec9WeL4xmSvBCyMsqi~.

*** How to generate test Bitcoins

**** Preconditions    

 * BTC testnet shell is open (see step 1 of the section *How to check balance* on how to do this).

**** Process

***** Step 1: Check balance

See section *How to check the balance* above. Note the amount.
      
***** Step 2: Generate test Bitcoins
     
~bitcoin-cli generatetoaddress 200 <address>~

where ~<address>~ is the address you generated with ~bitcoin-cli getnewaddress~.

***** Step 3: Check the balance again

This time it should be larger than at step 1.

*** How to send test Bitcoins to an Electrum wallet

**** Preconditions

 * Steps in section *How to start the whole thing* executed.
 * Electrum Wallet application installed

**** Step 1: Start the Electrum wallet in ~regtest~ mode

On MacOS you can do it using ~open /Applications/Electrum.app --args --regtest~.     

**** Step 2: Set up a wallet in Electrum (if not done already)

Follow the wizard after the startup.

**** Step 3: Determine the address of the Electrum wallet

Go to the ~Receive~ tab.

[[file:docs/img/2021-09-18_03.png]]

Click on the ~New address~ button.

[[file:docs/img/2021-09-18_04.png]]

The red rectangle in the screenshot above shows the address of the Electrum wallet.

**** Step 4: Open the BTC testnet shell

See *Step 1: Open the shell of BTC testnet* in section *How to check the balance* above.

**** Step 5: Send test BTC to the Electrum wallet

Run ~bitcoin-cli sendtoaddress <Address> 1~ in the BTC testnet shell where ~<Address>~ is the address from step 3.

[[file:docs/img/2021-09-18_05.png]]

Thereafter the sent amount should appear in the Electrum wallet.

[[file:docs/img/2021-09-18_06.png]]

*** How to send test ETH to the exchange account

See [[https://dpisarenko.com/posts/eth-transfers/][this blog post]].    

* License (MIT)

Copyright 2021, 2022 Dmitrii Pisarenko

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

* Contributors

  * [[https://www.linkedin.com/in/dmitrii-pisarenko-1149a5201][Dmitrii Pisarenko]]
  * [[https://www.linkedin.com/in/caleb-m-demel][Caleb Demel]]
  * [[https://www.linkedin.com/in/ronnie-liu-11155352][RonnieLiu]]