Skip to content
This repository was archived by the owner on Aug 24, 2023. It is now read-only.

Commit faacc82

Browse files
fuxingloheli-lim
andauthored
docs(token-bridge): add draft for MetaChain Token & Bridge (#102)
<!-- Thanks for sending a pull request! --> #### What this PR does / why we need it: As per the title, this PR is a working draft version of MetaChain Token & Bridge. Signed-off-by: Fuxing Loh <[email protected]> Co-authored-by: Eli <[email protected]>
1 parent 9799411 commit faacc82

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

docs/:300:MetaChain Protocol/:300:token-bridge.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,116 @@ title: MetaChain Tokens & Bridge
66
Currently work in progress — this article/page is consider draft, the information reflected here might not be
77
up-to-date.
88
:::
9+
10+
A blockchain bridge, also known as a network bridge, allows assets to be moved between different Blockchains. Bridges
11+
facilitate information transfer between separate networks, enabling assets to be moved between blockchain
12+
ecosystems. Generally, there are 2 types of bridges, Trusted Bridges and Trustless Bridges.
13+
14+
## Types of bridge
15+
16+
> To better understand MetaChain Tokens & Bridge design, you will first need to understand the different types of
17+
> bridges deployed today. See [ethereum.org/bridges/#types-of-bridge](https://ethereum.org/en/bridges/#types-of-bridge).
18+
19+
| **Trusted Bridges** | **Trustless Bridges** |
20+
| ------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
21+
| Trusted bridges depend upon a central entity or system for their operations. | Trustless bridges operate using smart contracts and algorithms. |
22+
| They have trust assumptions with respect to the custody of funds and the security of the bridge. Users mostly rely on the bridge operator's reputation. | They are trustless; the security of the bridge is the same as that of the underlying blockchain. |
23+
| Users need to give up control of their crypto assets. | Through smart contracts, trustless bridges enable users to remain in control of their funds. |
24+
25+
In a nutshell, we can say that trusted bridges have trust assumptions, whereas trustless bridges are trust-minimized and
26+
don’t make new trust assumptions beyond those of the underlying domains. Here’s how these terms can be described:
27+
28+
- **Trustless**: having equivalent security to the underlying domains.
29+
- **Trust assumptions**: moving away from the security of the underlying domains by adding external verifiers in the
30+
system, thus making it less crypto-economically secure.
31+
32+
## MetaChain Trustless Bridge
33+
34+
DeFiChain Native<->Meta Bridge is a trustless bidirectional asset bridging between NativeChain (UTXO) and MetaChain
35+
(Account). MetaChain Bridge has the equivalent security of a trustless bridge without the security worries of the underlying
36+
domains. MetaChain and NativeChain operate under the same domain, and the same [consensus](/consensus) mechanism within
37+
the same ecosystem keeps the validators honest.
38+
39+
DeFiChain introduces a set of Smart Contracts on each platform/chain to perform the bidirectional minting and burning.
40+
The supply of all DFI comes from the NativeChain; all DFI on MetaChain are bridged from the NativeChain.
41+
42+
### Trustless Bridge Smart Contract
43+
44+
```mermaid
45+
classDiagram
46+
class DfTxMetaBridge {
47+
+BigDecimal balance
48+
+send(pubKey, amount)
49+
+receive(MetaChain.txid, amount)
50+
}
51+
52+
class MetaChainBridgeContract {
53+
+BigDecimal balance
54+
+send(pubKey, amount)
55+
+receive(NativeChain.txid, amount)
56+
}
57+
```
58+
59+
**NativeChain Asset Bridge Native Contract**
60+
61+
- `DfTx.MetaChain.send(pubKey, amount)`
62+
- `DfTx.MetaBridge.receive(MetaChain.txid, amount)`
63+
64+
**MetaChain Asset Bridge EVM Contract**
65+
66+
- `MetaChain.BridgeContract.send(pubKey, amount)`
67+
- `MetaChain.BridgeContract.receive(NativeChain.txid, amount)`
68+
69+
### Validating & Finalizing
70+
71+
MetaChain trustless bridge actions are atomic and finalized within a single block. Each `send` requires an
72+
equivalent `receive` on the other chain within the same block. When a `txid = DfTx.MetaBridge.send(pubKey, 1.0)`
73+
transaction is present on the NativeChain, an equivalent `MetaChain.BridgeContract.receive(txid, 1.0)` must be present
74+
on the MetaChain.
75+
76+
All `*.receive` transactions will be automatically created by the DeFiChain consensus and included in the coinbase
77+
transaction for block import. Validators connecting blocks with the bridge transactions validate the legitimacy of each
78+
block by validating that each `*.receive` has an equivalent `*.send` transaction.
79+
80+
```mermaid
81+
stateDiagram-v2
82+
83+
state "User Initiated & Prepare Bridge Transaction" as 0
84+
state "NativeChain to MetaChain" as NM
85+
state "MetaChain to NativeChain" as MN
86+
87+
[*] --> 0
88+
0 --> NM : Broadcast
89+
0 --> MN : Broadcast
90+
91+
state NM {
92+
state "MetaBridge.send(0x00, 10.0)" as NM1
93+
state "BridgeContract.receive(txid, 10.0)" as NM2
94+
95+
[*] --> NM1
96+
NM1 --> NM2 : Bridge Consensus
97+
NM2 --> [*]
98+
}
99+
100+
state MN {
101+
state "BridgeContract.send(0x00, 15.0)" as MN1
102+
state "MetaBridge.receive(txid, 15.0)" as MN2
103+
104+
[*] --> MN1
105+
MN1 --> MN2 : Bridge Consensus
106+
MN2 --> [*]
107+
}
108+
109+
MN --> Validators : Added to Block
110+
NM --> Validators : Added to Block
111+
112+
state Validators {
113+
state "Connect Block" as cb1
114+
state "Process *.receive Transactions" as cb2
115+
116+
[*] --> cb1
117+
cb1 --> cb2
118+
cb2 --> False: missing *.send
119+
cb2 --> True : found equivalent *.send
120+
}
121+
```

0 commit comments

Comments
 (0)