create account

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

View this thread on: hive.blogpeakd.comecency.com
· @edicted ·
$19.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. 
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 140 others
πŸ‘Ž  
properties (23)
authoredicted
permlinkthis-is-bullshit-escrow-smart-contract-testing
categoryescrow
json_metadata"{"app":"peakd/2020.05.5","format":"markdown","description":"Devs love to hate themselves and their job. ","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
children24
last_payout2020-06-28 00:53:27
cashout_time1969-12-31 23:59:59
total_payout_value10.584 HBD
curator_payout_value8.828 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5,029
author_reputation3,487,921,183,932,524
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,085,913
net_rshares47,847,841,206,169
author_curate_reward""
vote details (205)
@cmplxty ·
$0.03
Damn that’s some solid work man. I’m intrigued by this, glad you talked about it again it’s been a bit. Would be really cool to do this over encrypted memo’s so that fuckers can’t keep tabs on some of the transactions details. Create dummy accounts to get the transactions done and keep it off the exchanges. 

A thing I wonder though, if we start doing this how long before pressure gets put on the witnesses to stop allowing it? The beauty of crypto is the ability to innovate but exchanges are the monopolies of all the transactions, they will hate the new exchange free process. I would love it!
πŸ‘  ,
properties (23)
authorcmplxty
permlinkre-edicted-2020620t21733970z
categoryescrow
json_metadata{"tags":["escrow","palnet","leofinance","hivedev","dsteem","hivejs"],"app":"esteem/2.2.5-mobile","format":"markdown+html","community":"hive-125125"}
created2020-06-21 01:07:33
last_update2020-06-21 01:07:33
depth1
children8
last_payout2020-06-28 01:07:33
cashout_time1969-12-31 23:59:59
total_payout_value0.016 HBD
curator_payout_value0.013 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length599
author_reputation772,561,134,200,038
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries
0.
accountesteemapp
weight300
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,022
net_rshares149,707,220,820
author_curate_reward""
vote details (2)
@edicted ·
Hm that's actually a really good idea to set up all the details using memo encryption... then only the 3 accounts involved would know which Bitcoin address was getting funded.  The only drawback to this is if the escrow agent turns out to be a bad actor and there is no proof that they colluded with one party to steal funds.  Still, I'm guessing the value of privacy and the trust that people acquire around here would be worth it to have that optional feature. 
πŸ‘  
properties (23)
authoredicted
permlinkre-cmplxty-qc94ri
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 01:14:06
last_update2020-06-21 01:14:06
depth2
children1
last_payout2020-06-28 01:14:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length463
author_reputation3,487,921,183,932,524
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,090
net_rshares6,416,646,927
author_curate_reward""
vote details (1)
@cmplxty ·
$0.02
Yeah I mean the escrow account will have to be trusted to perform these encrypted transactions I think but once they are, it opens the door to even more privacy than we currently have. Intriguing thought! Go make it happen lol 
πŸ‘  
properties (23)
authorcmplxty
permlinkre-edicted-2020620t213435601z
categoryescrow
json_metadata{"tags":["esteem"],"app":"esteem/2.2.5-mobile","format":"markdown+html","community":"hive-125125"}
created2020-06-21 01:34:36
last_update2020-06-21 01:34:36
depth3
children0
last_payout2020-06-28 01:34:36
cashout_time1969-12-31 23:59:59
total_payout_value0.012 HBD
curator_payout_value0.012 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length227
author_reputation772,561,134,200,038
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries
0.
accountesteemapp
weight300
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,406
net_rshares106,660,802,939
author_curate_reward""
vote details (1)
@edicted ·
$0.33
Also on that other note I'd be very curious to see how much flak the witnesses get for allowing this behavior.  We absolutely must test the boundaries of this network to see how decentralized we really are.  It may turn out to be an excellent opportunity to get witnesses from other countries that have much more lax financial laws. 

The witnesses also have a great excuse.  They are not the ones broadcasting these operations.  If the operations being broadcast were somehow deemed illegal, it's hard to go after a witness just for being a small part of the network.  Even if escrow services for Hive were eliminated we could simply make a new permissionless token and remake them stronger than ever. 
πŸ‘  
properties (23)
authoredicted
permlinkre-cmplxty-qc9508
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 01:19:21
last_update2020-06-21 01:19:21
depth2
children5
last_payout2020-06-28 01:19:21
cashout_time1969-12-31 23:59:59
total_payout_value0.166 HBD
curator_payout_value0.167 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length703
author_reputation3,487,921,183,932,524
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,145
net_rshares1,240,466,280,233
author_curate_reward""
vote details (1)
@brianoflondon ·
$0.08
I want to highlight this to @apshamilton. He's long said to me that transactions on a blockchain network should be considered exactly as any other speech and in this respect, platform owners, Witnesses in our case here, should be fully insulated from whatever speech occurs at least under the US's 1st Amendment. The only people responsible would be those carrying it out.
πŸ‘  
properties (23)
authorbrianoflondon
permlinkre-edicted-qc9isy
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 06:17:27
last_update2020-06-21 06:17:27
depth3
children4
last_payout2020-06-28 06:17:27
cashout_time1969-12-31 23:59:59
total_payout_value0.038 HBD
curator_payout_value0.038 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length372
author_reputation759,674,214,959,955
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,089,323
net_rshares319,446,137,472
author_curate_reward""
vote details (1)
@culgin · (edited)
$0.05
I read about this escrow function on Steem (now Hive) before and I thought it is very useful. But as you mentioned, I am not sure why I don't see projects using it. It can be use for DEXs and DeFi, basically anything that requires a 3rd party custodian can potentially make use of this feature. 
πŸ‘  
properties (23)
authorculgin
permlinkre-edicted-qc96w2
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 02:00:03
last_update2020-06-21 02:01:27
depth1
children1
last_payout2020-06-28 02:00:03
cashout_time1969-12-31 23:59:59
total_payout_value0.022 HBD
curator_payout_value0.023 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length295
author_reputation170,100,255,531,223
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,774
net_rshares192,260,702,354
author_curate_reward""
vote details (1)
@sames ·
Just DAO it and boom you can make a MakerDAO ;)
properties (22)
authorsames
permlinkqca4z0
categoryescrow
json_metadata{"app":"hiveblog/0.1"}
created2020-06-21 14:16:09
last_update2020-06-21 14:16:09
depth2
children0
last_payout2020-06-28 14:16:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length47
author_reputation39,585,633,843,789
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,094,849
net_rshares0
@fulltimegeek · (edited)
> Again, it's really hard to believe that no one is really using these things.

100%
properties (22)
authorfulltimegeek
permlinkre-edicted-qchy5a
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.10.9"}
created2020-06-25 19:29:33
last_update2020-10-29 18:34:33
depth1
children0
last_payout2020-07-02 19:29:33
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length84
author_reputation82,542,358,852,913
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,175,748
net_rshares0
@partitura ·
$0.04
I can imagine these micro transactions work on a one to one basis where the parties know each other. If I knew someone who would want to buy Steem from me and sell some Hive then we could set this up. 
But what if buyer and seller don't know each other? How do they discover each other? How does a pseudo-dex scale? 
πŸ‘  
properties (23)
authorpartitura
permlinkre-edicted-2020621t102056682z
categoryescrow
json_metadata{"tags":["escrow","palnet","leofinance","hivedev","dsteem","hivejs"],"app":"esteem/2.2.5-mobile","format":"markdown+html","community":"hive-125125"}
created2020-06-21 08:20:57
last_update2020-06-21 08:20:57
depth1
children5
last_payout2020-06-28 08:20:57
cashout_time1969-12-31 23:59:59
total_payout_value0.017 HBD
curator_payout_value0.018 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length317
author_reputation96,586,309,614,689
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries
0.
accountesteemapp
weight300
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,090,763
net_rshares157,182,803,750
author_curate_reward""
vote details (1)
@edicted ·
$0.04
### Thanks for asking
You set up a Web/Hive frontend that shows people who post their intention to trade Hive for BTC and BTC for Hive.  We have embedded custom JSON for this.  The two parties do not have to know each other, they simply have to trust the same middle man (escrow agent account).  

There are various ways to build up a history and a reputation for this.  The frontend can even recommend escrow accounts they feel are trusted entities for new users who have no idea who they can trust.  In fact, I would probably have my own escrow account (or at least our witness team would) so they would also be on the list of trusted accounts as well. 

I think the Biggest problem would be onboarding users that don't have a Hive account yet.  We do have various ways to do this but it isn't super streamlined yet and the way we do things is a bit different and might confuse users from other chains who haven't heard about us yet. 
πŸ‘  
properties (23)
authoredicted
permlinkre-partitura-qcaj1d
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 19:20:03
last_update2020-06-21 19:20:03
depth2
children4
last_payout2020-06-28 19:20:03
cashout_time1969-12-31 23:59:59
total_payout_value0.018 HBD
curator_payout_value0.018 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length936
author_reputation3,487,921,183,932,524
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,099,188
net_rshares164,239,721,091
author_curate_reward""
vote details (1)
@partitura ·
$0.03
Someone still has to setup the front end, and that's a bit like a 'real' dex. So isn't this still a bit centralised? (not meant as criticism, just me, thinking along your lines).
πŸ‘  
properties (23)
authorpartitura
permlinkre-edicted-qcajn1
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 19:33:00
last_update2020-06-21 19:33:00
depth3
children3
last_payout2020-06-28 19:33:00
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.014 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length178
author_reputation96,586,309,614,689
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,099,404
net_rshares129,332,052,948
author_curate_reward""
vote details (1)
@sepracore ·
$0.03
I have a potential Hive use case that you might be able to address.

I should start off by saying I do not even know if this is possible or even desirable.  It is more of a question I have had but do not have enough technical knowledge to answer. The other way to say it is ... this is likely a stupid question. 

Can dApps, etc that are built and run on other blockchains utilize Hive to get around the β€œgas feesβ€œ that they are paying?  Your article reminded me of this question.

Basically, could Hive be used as a backdoor to lower people’s cost to operate? Hive would win because these people would need RCs. I guess this is what splinterlands is basically doing, right? 

Or would this essentially be the equivalent of a dApps moving to Hive?

I know so little, I do not even truly know how to phrase the question.
πŸ‘  
properties (23)
authorsepracore
permlinkre-edicted-qc97pp
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 02:18:21
last_update2020-06-21 02:18:21
depth1
children4
last_payout2020-06-28 02:18:21
cashout_time1969-12-31 23:59:59
total_payout_value0.014 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length819
author_reputation19,888,382,618,059
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,973
net_rshares127,976,901,175
author_curate_reward""
vote details (1)
@edicted ·
$0.17
That kind of just sounds like a dapp porting it's functionality to Hive.  There's nothing to stop a frontend from connecting to multiple blockchains.  We usually call something like that interoperability. 

There is no way to get around an Ethereum gas fee if you want the security of the Ethereum blockchain.  However, if parts of your dapp required less security you could probably migrate those parts to other DPOS chains with free trx costs. It's an interesting thought. 
πŸ‘  
properties (23)
authoredicted
permlinkre-sepracore-qc9ixz
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 06:20:24
last_update2020-06-21 06:20:24
depth2
children3
last_payout2020-06-28 06:20:24
cashout_time1969-12-31 23:59:59
total_payout_value0.086 HBD
curator_payout_value0.087 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length475
author_reputation3,487,921,183,932,524
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,089,367
net_rshares696,187,039,336
author_curate_reward""
vote details (1)
@sepracore ·
$0.03
Thanks. Yea, I know nothing about other blockchains (or very little) so it is hard for me to know where someone could cut corners but maintain the security of say an Ethereum blockchain. I do not exactly know when the gas fees occur.

Thanks. 
πŸ‘  
properties (23)
authorsepracore
permlinkre-edicted-qc9m0j
categoryescrow
json_metadata{"tags":["escrow"],"app":"peakd/2020.05.5"}
created2020-06-21 07:26:45
last_update2020-06-21 07:26:45
depth3
children2
last_payout2020-06-28 07:26:45
cashout_time1969-12-31 23:59:59
total_payout_value0.015 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length243
author_reputation19,888,382,618,059
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,090,076
net_rshares134,720,974,643
author_curate_reward""
vote details (1)
@taskmaster4450le ·
$0.04
Very interesting.  You are a lot more technical than I am so it was refreshing to read your explanation of all this.

It is very intriguing and does appear you tapped into something that holds great potential yet is overlooked.  Naturally, anything that avoids the powers that are and "sticks it to them" by avoiding KYC/AML strings a nice chord with me.

I look forward to your continued experimentation with this.  Hopefully some of the more technical people see this is start to help out.

It does hold possibilities it seems.

Posted Using [LeoFinance](https://leofinance.io/@taskmaster4450le/qc957y)
πŸ‘  
properties (23)
authortaskmaster4450le
permlinkqc957y
categoryescrow
json_metadata{"tags":["leofinance"],"app":"leofinance/0.1","canonical_url":"https://leofinance.io/@taskmaster4450le/qc957y"}
created2020-06-21 01:24:00
last_update2020-06-21 01:24:00
depth1
children0
last_payout2020-06-28 01:24:00
cashout_time1969-12-31 23:59:59
total_payout_value0.022 HBD
curator_payout_value0.022 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length604
author_reputation2,168,751,753,713,616
root_title""This is bullshit!": Escrow Smart-Contract Testing"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id98,086,231
net_rshares184,581,184,817
author_curate_reward""
vote details (1)