Technical Architecture

Cross-chain transactions

Cross-chain transactions

Single chain mechanism: link

Abbreviations used

U1 → User 1

U2 → User 2

A1 → Agent 1

A2 → Agent 2

E1 → Escrow of user 1

E2 → Escrow of user 2

Explanations and write-up

This more advanced version of agent-based trading enables cross-chain transfers using a p2p trading mechanism.

Agents can listen and interact with multiple blockchains simultaneously. The agent match mechanism works the same as it does otherwise. The entire flow looks like this:

  • U1 locks funds on blockchain 1; U2 locks funds in blockchain 2 (not in the diagram)

  • The agent listens on the blockchain(s) where the user has his escrow(s) present. In this case, A1 listens on blockchain 1, where the escrow of U1 is present (E1). Similarly, A2 listens on blockchain 2, where the escrow of U2 is present (E2).

Agents can also listen on multiple blockchains simultaneously. If U1 has its escrows on multiple chains, A1 will monitor all of them.

  • As a user places his order, the agent will be notified (listening to escrow on the blockchain). Once the agent has this knowledge, it will look for other agents to find a matching trade pair, exactly as agents did during the single-chain mechanism.

  • Once matched, the cross-chain system will start to work.

Push Mechanism

  1. Agents matched.

  2. The agent locks the order, making it no longer discoverable to other agents. The agent then sends this order lock acknowledgement along with its balance for the blockchain on which its user has locked funds. Here, A1 sends its balance of blockchain 1 to A2.

  3. The matching Agent (A2) verifies the balance sent by A1, locks its matching order, and responds similarly to A1.

  4. Once a response is received, Agents independently lock the orders in their respective escrows. This is done so that the user or the agent can’t take action with these funds while a transfer is going on.

  5. The agents listen to the response by blockchain of lock order txn confirmation.

  6. Agents share the details of the lock order txn they have performed and the new balances they now have after performing the lock txn in escrow.

  7. The agent verifies the txn performed and the balance of the matching agent and then proceeds to order funds transfer to its escrow. (A1 would verify if A2 has performed the txn and A2 has sufficient balance to perform further txns, then orders funds to be transferred from E1 to U2).

  8. The escrow transfers funds to the opposing user.

Pull Mechanism - Fail safe

The pull mechanism is similar to the push mechanism and is a fail-safe method in case of a failure in mid-transaction. This works until step 6 (lock order acknowledgements) and funds transfer from one party.

  1. Transfer of funds order given by A1 to E1.

  • At this point, A2 failed to transfer funds due to unforeseen circumstances. We need a fail-safe mechanism for U1 to receive his funds, which are now locked in E2.

  1. Funds are transferred to U2 from E1 as ordered by A1.

  2. if funds aren’t received by U1 in a specific time, say T1, U1 then asks his agent (A1) to retrieve funds for him.

  3. A1, using its funds on chain 2, issues an order to ‘pull’ funds on behalf of U1 to E2.

  4. E2 transfers the funds to U1 after receiving the order from A1.

Single chain mechanism: link

Abbreviations used

U1 → User 1

U2 → User 2

A1 → Agent 1

A2 → Agent 2

E1 → Escrow of user 1

E2 → Escrow of user 2

Explanations and write-up

This more advanced version of agent-based trading enables cross-chain transfers using a p2p trading mechanism.

Agents can listen and interact with multiple blockchains simultaneously. The agent match mechanism works the same as it does otherwise. The entire flow looks like this:

  • U1 locks funds on blockchain 1; U2 locks funds in blockchain 2 (not in the diagram)

  • The agent listens on the blockchain(s) where the user has his escrow(s) present. In this case, A1 listens on blockchain 1, where the escrow of U1 is present (E1). Similarly, A2 listens on blockchain 2, where the escrow of U2 is present (E2).

Agents can also listen on multiple blockchains simultaneously. If U1 has its escrows on multiple chains, A1 will monitor all of them.

  • As a user places his order, the agent will be notified (listening to escrow on the blockchain). Once the agent has this knowledge, it will look for other agents to find a matching trade pair, exactly as agents did during the single-chain mechanism.

  • Once matched, the cross-chain system will start to work.

Push Mechanism

  1. Agents matched.

  2. The agent locks the order, making it no longer discoverable to other agents. The agent then sends this order lock acknowledgement along with its balance for the blockchain on which its user has locked funds. Here, A1 sends its balance of blockchain 1 to A2.

  3. The matching Agent (A2) verifies the balance sent by A1, locks its matching order, and responds similarly to A1.

  4. Once a response is received, Agents independently lock the orders in their respective escrows. This is done so that the user or the agent can’t take action with these funds while a transfer is going on.

  5. The agents listen to the response by blockchain of lock order txn confirmation.

  6. Agents share the details of the lock order txn they have performed and the new balances they now have after performing the lock txn in escrow.

  7. The agent verifies the txn performed and the balance of the matching agent and then proceeds to order funds transfer to its escrow. (A1 would verify if A2 has performed the txn and A2 has sufficient balance to perform further txns, then orders funds to be transferred from E1 to U2).

  8. The escrow transfers funds to the opposing user.

Pull Mechanism - Fail safe

The pull mechanism is similar to the push mechanism and is a fail-safe method in case of a failure in mid-transaction. This works until step 6 (lock order acknowledgements) and funds transfer from one party.

  1. Transfer of funds order given by A1 to E1.

  • At this point, A2 failed to transfer funds due to unforeseen circumstances. We need a fail-safe mechanism for U1 to receive his funds, which are now locked in E2.

  1. Funds are transferred to U2 from E1 as ordered by A1.

  2. if funds aren’t received by U1 in a specific time, say T1, U1 then asks his agent (A1) to retrieve funds for him.

  3. A1, using its funds on chain 2, issues an order to ‘pull’ funds on behalf of U1 to E2.

  4. E2 transfers the funds to U1 after receiving the order from A1.

Single chain mechanism: link

Abbreviations used

U1 → User 1

U2 → User 2

A1 → Agent 1

A2 → Agent 2

E1 → Escrow of user 1

E2 → Escrow of user 2

Explanations and write-up

This more advanced version of agent-based trading enables cross-chain transfers using a p2p trading mechanism.

Agents can listen and interact with multiple blockchains simultaneously. The agent match mechanism works the same as it does otherwise. The entire flow looks like this:

  • U1 locks funds on blockchain 1; U2 locks funds in blockchain 2 (not in the diagram)

  • The agent listens on the blockchain(s) where the user has his escrow(s) present. In this case, A1 listens on blockchain 1, where the escrow of U1 is present (E1). Similarly, A2 listens on blockchain 2, where the escrow of U2 is present (E2).

Agents can also listen on multiple blockchains simultaneously. If U1 has its escrows on multiple chains, A1 will monitor all of them.

  • As a user places his order, the agent will be notified (listening to escrow on the blockchain). Once the agent has this knowledge, it will look for other agents to find a matching trade pair, exactly as agents did during the single-chain mechanism.

  • Once matched, the cross-chain system will start to work.

Push Mechanism

  1. Agents matched.

  2. The agent locks the order, making it no longer discoverable to other agents. The agent then sends this order lock acknowledgement along with its balance for the blockchain on which its user has locked funds. Here, A1 sends its balance of blockchain 1 to A2.

  3. The matching Agent (A2) verifies the balance sent by A1, locks its matching order, and responds similarly to A1.

  4. Once a response is received, Agents independently lock the orders in their respective escrows. This is done so that the user or the agent can’t take action with these funds while a transfer is going on.

  5. The agents listen to the response by blockchain of lock order txn confirmation.

  6. Agents share the details of the lock order txn they have performed and the new balances they now have after performing the lock txn in escrow.

  7. The agent verifies the txn performed and the balance of the matching agent and then proceeds to order funds transfer to its escrow. (A1 would verify if A2 has performed the txn and A2 has sufficient balance to perform further txns, then orders funds to be transferred from E1 to U2).

  8. The escrow transfers funds to the opposing user.

Pull Mechanism - Fail safe

The pull mechanism is similar to the push mechanism and is a fail-safe method in case of a failure in mid-transaction. This works until step 6 (lock order acknowledgements) and funds transfer from one party.

  1. Transfer of funds order given by A1 to E1.

  • At this point, A2 failed to transfer funds due to unforeseen circumstances. We need a fail-safe mechanism for U1 to receive his funds, which are now locked in E2.

  1. Funds are transferred to U2 from E1 as ordered by A1.

  2. if funds aren’t received by U1 in a specific time, say T1, U1 then asks his agent (A1) to retrieve funds for him.

  3. A1, using its funds on chain 2, issues an order to ‘pull’ funds on behalf of U1 to E2.

  4. E2 transfers the funds to U1 after receiving the order from A1.

Mettalex is the world’s first AI agent-based P2P order book DEX, designed to make digital asset trading efficient.

© Mettalex, 2024. All rights reserved.

Mettalex is the world’s first AI agent-based P2P order book DEX, designed to make digital asset trading efficient.

© Mettalex, 2024. All rights reserved.

Mettalex is the world’s first AI agent-based P2P order book DEX, designed to make digital asset trading efficient.

© Mettalex, 2024. All rights reserved.