Protocol

The YAR protocol implements a network for delivering on-chain transactions to external networks. It consists of the following elements:

  1. A standard EVM transaction that needs to be delivered

  2. The YarRequest smart contract, which serves as the entry point

  3. The YarResponse smart contract, responsible for on-chain transaction delivery

  4. The YarHub the smart contract, located only in YarChain, represents a mempool of cross-chain transactions

  5. The Solidity structure YarLib.YarTX, a wrapper around a standard EVM transaction with additional metadata

  6. The EVM-compatible blockchain YarChain

  7. A network of validators known as Relayers

These elements are combined in the following sequence:

  1. The initiator (EOA wallet or smart contract) calls YarRequest.send(...)

  2. YarRequest generates a Send event

  3. Upon receiving the Send event, Relayers add the pending transaction to YarHub

  4. After adding the transaction to the queue, Relayers move transactions into execution, locking a sufficient amount of fees

  5. Relayers call YarResponse.deliver(...), which executes the transaction to the destination address

  6. After executing the transaction, Relayers update the transaction status and return any unspent fees

0. Standard EVM Transaction

There are no restrictions on the transactions being sent:

  1. The address in the external network does not need to conform to any specific interface; transactions can be delivered even to EOA wallets

  2. The transaction can transfer the native token, i.e., use the [value] parameter

  3. The transaction can represent another cross-chain call, allowing complex sequences of data transfers across multiple networks

1. YarRequest Smart Contract

The starting point of the protocol. It is responsible for sending events to validators.

There are 3 types of unique events:

  1. Send - sends a cross-chain transaction

  1. Deposit - replenishes the balance, which is debited to pay for cross-chain transactions

  1. Approve - similar to EIP20.approve. Allows applications to debit the user's balance to pay for their cross-chain transaction

Each event corresponds to a function of the same name:

  1. send - accepts YarLib.YarTX and sends it to the Relayers network

  1. deposit - accepts tokens (native or EIP20) from the user

  1. approve - allows the [spender] to debit [amount] YarToken from the user's deposit

2. YarResponse Smart Contract

Acts as the entry point for sending transactions by the Relayers network. This is done via the deliver function, which deploys the cross-chain transaction [yarTx] and delivers it to the recipient.

Additionally, this smart contract is used by applications for authorization if their recipient function should only accept calls from Relayers and not any address.

Temporarily, it stores the metadata of the current cross-chain transaction, which can be accessed in the trustedYarTx function. The metadata is recorded before the call and deleted immediately afterward.

!!! Passing flags to enable/disable writing trustedYarTx fields to storage can save gas.

3. YarHub Smart Contract

YarHub stores all pending, executed, and unexecuted cross-chain transactions, which are accessible in the wrappedYarTXs mapping.

To access a specific transaction [yarTx], the key used is the keccak hash of the entire YarLib.YarTx model.

You can also obtain the identifying hash of a cross-chain transaction using the [YarHub.getYarTxHash] method.

YarHub also stores user deposits in Yar tokens, which are used to pay for transaction fees. The balance is credited to the deposit only from the relayer’s address after processing the Deposit event. To view the current balance:

4. Solidity Structure YarLib.YarTX

Last updated

Was this helpful?