"This is bullshit!": Escrow Smart-Contract Testing by edicted

View this thread on steempeak.com
· @edicted ·
$3.41
"This is bullshit!": Escrow Smart-Contract Testing
<center>![t1.png](https://files.peakd.com/file/peakd-hive/edicted/lTjM9ysy-t1.png)
</center>


I've been talking about the value of escrow smart-contracts for quite some time now so I figured it was FINALLY time to start testing them out.  I think using these smart contracts I can set up a pseudo-DEX that allows us to easily trade Hive and Steem back and forth, and even connect Graphene-based coins to other networks like Bitcoin without the need of a regulated centralized authority. 

<div class="pull-right">https://files.peakd.com/file/peakd-hive/edicted/uCkIN7ds-t2.png
   </div>

Instead of using a regulated centralized authority like Binance, Coinbase, or Bittrex we can simply use any "agent" account.  An agent is simply an account that approves the escrow operation to move forward.  It could be a friend you know personally on Hive/Steem.  It could be someone that has a reputation for being trustworthy.  It could be anyone.  

I want to use these same contracts to not only implement this pseudo-DEX for under-the-table trades, but also for all of my gambling dapp ideas.  The most basic one will simply be flipping a coin and seeing who wins.  The next idea would be my rock/paper/scissors clone called @Pentaskill.  There really is no limit to the kinds of speculative transactions one can make with these contracts, and no one seems to be using them, which I find quite odd, as there is a built in mechanic to monetize the trust using escrow agent fees. 

-----------







https://files.peakd.com/file/peakd-hive/edicted/7QCrEnnb-bang-head-programming-grind.gif

In any case, I tried to get this started by doing the first transaction of an escrow contract, which is the [EscrowTransferOperation](https://jnordberg.github.io/dsteem/interfaces/escrowtransferoperation.html).  The problem?  It doesn't work with the API that I've been practicing this whole time (dsteem).  It kept telling me I didn't have the proper "active key Authority" which means it said my private active key was wrong.  It wasn't.  I was using the same credentials to move money around, thus the dozens of 0.001 Steem transactions from @edicted to @dexturd with the memo "this is bullshit". 

My Witness team (@rishi556 & @sn0n) tried to help me out a bit, but in the end we realized that dsteem simply does not work and had to use HiveJS.  This is really annoying and very telling about just how bad the documentation and backend api are for this network.  Devs can run into stupid problems like this and literally spend hours trying to solve them when it should only take a few minutes (or in this case should have never happened to begin with).  

Now I'm in a position where I probably have to switch APIs and try to relearn a few things.  It's not that big of a deal, as a lot of the code will look quite familiar, but it is quite annoying and frustrating to be told in the documentation that something is going to work and it just doesn't and that information is nowhere to be found. 

<center>![t1.png](https://files.peakd.com/file/peakd-hive/edicted/w37snjmH-t1.png)
</center>

So I've got it working with HiveJS with a lot of help from @rishi556
       
    <script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>

### Figured out a few things about escrow. 
To start, the second you broadcast the operation your account loses the money and it gets sent to a temporary account in no-man's-land.  No worries, the witnesses won't lose your money.  

* Both the <code>to</code> account and the <code>escrow</code> account must <code>EscrowApproveOperation</code> before the <code>ratification_deadline</code>.  Should that deadline pass everything gets canceled and you get the money back. 
* <code>escrow_id</code> must be a unique number and can not be used twice, but once your active escrow completes or otherwise becomes inactive, you can use the same escrow_id again. 
* If the escrow expires without a dispute either party can send the money to either party. 

# Conclusion
Again, it's really hard to believe that no one is really using these things.  For example, we could make a dapp that allows us to trade Hive for Bitcoin under-the-table.  Simply tell someone to send Bitcoin to X address, and when they do they will receive Hive to X account, guaranteed by the escrow system.  The fee for this transaction is whatever the <code>agent</code> charges, so if we allow anyone to be an agent some people will surely provide this service for a very small fee (lots of competition) or even for free.  It also avoids all the KYC rules because literally any account can be an escrow account and it would impossible to regulate such an operation. 

It's very disappointing that I'll probably need to start learning a new API (HiveJS) but I was never under the illusion that I could use dsteem forever; it's been abandon-ware for quite a while now.  It's just annoying that such an old feature that should work, clearly doesn't and it wasted a bunch of my time.  Whatever, live and learn I guess. 
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
👎  
properties (23)
post_id86,417,341
authoredicted
permlinkthis-is-bullshit-escrow-smart-contract-testing
categoryescrow
json_metadata{"app":"steempeak\/2020.06.1","format":"markdown","tags":["escrow","palnet","leofinance","hivedev","dsteem","hivejs"],"users":["Pentaskill","edicted","dexturd","rishi556","sn0n","hiveio"],"links":["\/@pentaskill","https:\/\/jnordberg.github.io\/dsteem\/interfaces\/escrowtransferoperation.html","\/@edicted","\/@dexturd","\/@rishi556","\/@sn0n","\/@rishi556"],"image":["https:\/\/files.peakd.com\/file\/peakd-hive\/edicted\/lTjM9ysy-t1.png","https:\/\/files.peakd.com\/file\/peakd-hive\/edicted\/uCkIN7ds-t2.png","https:\/\/files.peakd.com\/file\/peakd-hive\/edicted\/7QCrEnnb-bang-head-programming-grind.gif","https:\/\/files.peakd.com\/file\/peakd-hive\/edicted\/w37snjmH-t1.png"]}
created2020-06-21 00:53:27
last_update2020-06-21 00:53:27
depth0
children0
net_rshares5,570,283,454,187
last_payout2020-06-28 00:53:27
cashout_time1969-12-31 23:59:59
total_payout_value1.730 SBD
curator_payout_value1.679 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length5,029
author_reputation171,132,830,416,177
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (64)