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.
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. 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.
So I've got it working with HiveJS with a lot of help from @rishi556
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
to
account and theescrow
account mustEscrowApproveOperation
before theratification_deadline
. Should that deadline pass everything gets canceled and you get the money back. escrow_id
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 agent
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.
Return from "This is bullshit!": Escrow Smart-Contract Testing to edicted's Web3 Blog