133 lines
5.3 KiB
Markdown
133 lines
5.3 KiB
Markdown
|
# Bridging Contract
|
||
|
|
||
|
Is code which has the capability to bridge between multiple blockchains.
|
||
|
|
||
|
A bridging mechanism allows tokens to be transferred between different blockchains. Here's how it typically works:
|
||
|
|
||
|
1. A user sends tokens to the `src_bridge_address` on the source chain.
|
||
|
2. The bridging contract detects this transaction.
|
||
|
3. The lockers on the source chain verify and lock the tokens at the `src_lock_address`.
|
||
|
4. The minters on the destination chain are notified and create an equivalent amount of tokens on the destination chain.
|
||
|
5. The new tokens are released to the user's address on the destination chain.
|
||
|
6. The original tokens remain locked on the source chain until a reverse bridge operation is performed.
|
||
|
|
||
|
Here's an example JSON for a Bridging Contract:
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"bridging_contract": {
|
||
|
"name": "INCA_SOLANA_BNC_BRIDGE",
|
||
|
"description": "Bridging contract for INCA tokens between Solana and Binance Chain",
|
||
|
"address": "0x1234567890123456789012345678901234567890",
|
||
|
"src_token_name": "INCA",
|
||
|
"src_chain": "SOLANA",
|
||
|
"src_bridge_address": "0xABCDEF1234567890ABCDEF1234567890ABCDEF12",
|
||
|
"src_lock_address": "0x9876543210987654321098765432109876543210",
|
||
|
"dest_token_name": "INCA",
|
||
|
"dest_chain": "BNC",
|
||
|
"lockers": {
|
||
|
"lockers_multisig_accounts": [
|
||
|
"0x1111111111111111111111111111111111111111",
|
||
|
"0x2222222222222222222222222222222222222222",
|
||
|
"0x3333333333333333333333333333333333333333",
|
||
|
"0x4444444444444444444444444444444444444444",
|
||
|
"0x5555555555555555555555555555555555555555",
|
||
|
"0x6666666666666666666666666666666666666666",
|
||
|
"0x7777777777777777777777777777777777777777",
|
||
|
"0x8888888888888888888888888888888888888888",
|
||
|
"0x9999999999999999999999999999999999999999"
|
||
|
],
|
||
|
"lockers_multisig_min_signature": 6
|
||
|
},
|
||
|
"minters": {
|
||
|
"minter_multisig_accounts": [
|
||
|
"bnb1aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||
|
"bnb1bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||
|
"bnb1cccccccccccccccccccccccccccccccccccc",
|
||
|
"bnb1dddddddddddddddddddddddddddddddddddd",
|
||
|
"bnb1eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
||
|
"bnb1ffffffffffffffffffffffffffffffffffff",
|
||
|
"bnb1gggggggggggggggggggggggggggggggggggg",
|
||
|
"bnb1hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
|
||
|
"bnb1iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"
|
||
|
],
|
||
|
"minter_multisig_min_signature": 6
|
||
|
},
|
||
|
"smart_contract_addr": "0xFEDCBA9876543210FEDCBA9876543210FEDCBA98"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
This JSON structure represents a bridging contract for INCA tokens between Solana and Binance Chain. It includes:
|
||
|
|
||
|
1. Basic information about the bridge (name, description, address).
|
||
|
2. Source and destination chain details, including token names and relevant addresses.
|
||
|
3. Multisig requirements for lockers on the source chain.
|
||
|
4. Multisig requirements for minters on the destination chain.
|
||
|
5. The smart contract address that implements the bridging logic.
|
||
|
|
||
|
This structure allows for a secure and decentralized bridging process, requiring multiple signatures for locking tokens on the source chain, minting on the destination chain, and overall bridge operations.
|
||
|
|
||
|
### details about properties
|
||
|
|
||
|
- name
|
||
|
- description
|
||
|
- address, the address of this contract
|
||
|
- src_token_name e.g. INCA in case of ThreeFold
|
||
|
- src_chain e.g. SOLANA
|
||
|
- src_bridge_address
|
||
|
- address where tokens have been sent to which need to be bridged, they are locked untill executed
|
||
|
- src_lock_address
|
||
|
- once the tokens where created on the dest chain then on source they are locked
|
||
|
- dest_token_name e.g. INCA in case of ThreeFold
|
||
|
- dest_chain e.g. BNC
|
||
|
- the lockers on source
|
||
|
- lockers_multisig_accounts = list e.g 9 accounts
|
||
|
- lockers_multisig_min_signature: 6
|
||
|
- the minters on dest
|
||
|
- minter_multisig_accounts = list e.g 9 accounts
|
||
|
- minter_multisig_min_signature: 6
|
||
|
- multisig_accounts e.g. 9 accounts need to sign
|
||
|
- multisig_min_signature e.g. 6 need to sign, this is for releasing the generated token INCA
|
||
|
- smart_contract_addr: address of the smart contract
|
||
|
|
||
|
|
||
|
```mermaid
|
||
|
sequenceDiagram
|
||
|
participant User
|
||
|
participant SourceChain
|
||
|
participant BridgingContract
|
||
|
participant DestChain
|
||
|
|
||
|
User->>SourceChain: Send tokens to src_bridge_address
|
||
|
SourceChain->>BridgingContract: Notify of received tokens
|
||
|
BridgingContract->>SourceChain: Verify transaction
|
||
|
|
||
|
alt Transaction valid
|
||
|
BridgingContract->>SourceChain: Request token lock
|
||
|
SourceChain->>SourceChain: Lock tokens at src_lock_address
|
||
|
SourceChain-->>BridgingContract: Confirm lock
|
||
|
|
||
|
BridgingContract->>BridgingContract: Initiate multisig process
|
||
|
loop Until minimum signatures reached
|
||
|
BridgingContract->>BridgingContract: Collect locker signatures
|
||
|
end
|
||
|
|
||
|
BridgingContract->>DestChain: Request token minting
|
||
|
DestChain->>DestChain: Initiate minter multisig process
|
||
|
loop Until minimum signatures reached
|
||
|
DestChain->>DestChain: Collect minter signatures
|
||
|
end
|
||
|
|
||
|
DestChain->>DestChain: Mint equivalent tokens
|
||
|
DestChain->>User: Transfer minted tokens
|
||
|
DestChain-->>BridgingContract: Confirm minting and transfer
|
||
|
|
||
|
BridgingContract->>User: Notify successful bridge
|
||
|
else Transaction invalid
|
||
|
BridgingContract->>User: Notify failed bridge
|
||
|
end
|
||
|
```
|
||
|
|
||
|
|