Cross-Chain Commerce Trustless Trading of Tokens
- EVM ERC-20 (DeFi) • EVM ERC-721 (NFT) including:
- Stacks Clarity (CityCoins) • Bitcoin (Bitcoin)
Step 1: parties agree on the trade
Discover other parties to transact with
Connect over common interests and terms
Agree on the parameters of the trade
Sign the hash of the payload with trade info:
Blockchain 1: A sends to B amount X1 of token Y1 Blockchain 2: B sends to A amount X2 of token Y2 Blockchain 3: B sends to C amount X3 of token Y3
Step 2: parties lock money in escrow
on their respective blockchains
Time-Locked 3000 USDT in escrow contract A 0xA ... for 1 hour
Time-Locked 2 NFT tokens in escrow contract B 0xB ... for 1 hour
Step 3: parties verify each other's lockups
they only proceed to the next steps if satis ed
in the worst case, one party locked tokens for an hour fi
Step 4: parties post on each other's chains
!
! ! ! !
they must do it in the rst half of the timeout period
!
! ! ! !
Trade hash is signed by A
and posted on Blockchain 2
as a necessary condition
of receiving 2 NFTs
! ! !
Step 5: parties complete the transaction
!
! ! ! !
on each blockchain, tokens are released to the other party
only if they had posted a signed transaction in the rst half
!
! ! ! !
Trade hash is signed by B
and posted on Blockchain 1
as a necessary condition
of receiving 3000 USDT
! ! !
Trade hash is signed by A
and posted on Blockchain
as a necessary condition
of receiving 2 NFTs
! ! !
BA nds signature by A
!
that was posted on blockchain 2
and reposts it on blockchain 1
causing 3000 USDT to be released
to its address in the Trade.
! ! ! !
AA nds signature by B
that was posted on blockchain
and reposts it on blockchain 2
causing 2 NFTs to be released
to its addresses in the Trade.
! ! ! !
Canceling: what if one party doesn't post?
!
! ! ! !
suppose that B's transaction was never mined
in the rst half of the timeout period
!
! ! ! !
then the trade would be canceled on both blockchains,
as neither A nor B could complete it before the timeout.
! ! ! !
B takes tokens back
! ! !
Failure Mode: transactions being mined late
if B's rst transaction was delayed and mined after the halfway point
then A could repost it on Blockchain 2 (e.g. from mempool)
and receive B's tokens, even though B won't get A's tokens.
B A nds signature by A Trade hash is signed by B that was posted on blockchain 2 and posted on Blockchain 1 and reposts it on blockchain 1 but it was mined too late A but the rst one was posted too so B can't claim tokens late and so... A takes tokens back
time
half timeout
Trade hash is signed by A AA nds signature by B and posted on Blockchain 2 that was posted on blockchain 1 as a necessary condition and reposts it on blockchain 2 B of receiving 2 NFTs causing 2 NFTs to be released to its addresses in the Trade.
Same applies to transactions in the second half of the timeout.
Therefore, it's vital that the timeout period is long enough
and enough gas is spent by all parties to get transactions mined.
fi fi fi fi
Greg Magarshak
Founder, Architect
!
!
! !
Artem Subbotin
Smart Contract Developer
!
!
!
!
! ! !
Marsilda Bialczak
Media Director
!
!
!
!
!
! ! ! !
Stacey Brown
Community Director
!
!
!
! ! !
Chris Kim
DApp Developer
!
!
! ! !
Igor Martsekha
Native App Developer
!
!
!
! ! ! !