Bridge

Bridge smart contracts that allow users to move states between Ethereum and Taraxa chains.

Generated Foundry smart contract specs are available at: https://taraxa-project.github.io/bridge/index.html

Official Testnet Deployment

At the end of June 2024, the bridge was deployed on the official Taraxa testnet and serves as an active avenue to bridge tokens from ETH Holes to TARA and vice versa.

You can find out more about the deployment details in the TESTNET.md file.

Where to find important information

Main contracts

There are main contracts on both chains that are finalizing states(changes list) and applies state changes from the other chain. Changes are verified against the Bridge Root that is requested from the light clients and is verified against the other chain consensus.

Light clients

Ethereum light client

beacon-light-client

EthClient.sol

Ethereum light client is deployed on Taraxa side and it is accepting Ethereum block headers and verifying them against the Ethereum consensus. So after the finalization of Ethereum header we can take state root from it and verify Bridge Root against it.

Taraxa light client

TaraClient.sol

Taraxa light client will verify Taraxa Pillar blocks that are special type of blocks for this purpose. Pillar block will have Bridge Root in it, so we can directly use Bridge Root from it.

Connectors

Connectors are contracts that are deployed on both chains and they are:

  1. Finalizing state to transfer it to another chain.
  2. Applies changes from the other chain.

Interface could be found at IBridgeConnector.sol

Examples of connectors:

Scripts

The root Makefile contains a few useful commands that are used for development and testing.

make test

The scripts folder contains a few useful scripts that are used for development, deployment, contract registration and testing.

Contents

ConnectorUpgradeableBase

Git Source

Inherits: OwnableUpgradeable, UUPSUpgradeable

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

__ConnectorUpgradeableBase_init

function __ConnectorUpgradeableBase_init(address bridge) public onlyInitializing;

__ConnectorUpgradeableBase_init_unchained

function __ConnectorUpgradeableBase_init_unchained(address bridge) internal onlyInitializing;

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal override onlyOwner;

ERC20LockingConnector

Git Source

Inherits: ConnectorUpgradeableBase, Receiver, ERC20LockingConnectorLogic

Functions

initialize

function initialize(BridgeBase _bridge, IERC20 tokenAddress, address token_on_other_network) public payable initializer;

ERC20LockingConnectorLogic

Git Source

Inherits: TokenConnectorLogic

Functions

applyState

Applies the given state to the token contract by transfers.

function applyState(bytes calldata _state) public virtual override onlyBridge;

Parameters

NameTypeDescription
_statebytesThe state to be applied.

lock

The amount of tokens to burn must be approved by the sender

Locks the specified amount of tokens to transfer them to the other network.

function lock(uint256 value) public payable onlySettled;

Parameters

NameTypeDescription
valueuint256The amount of tokens to lock.

Events

Locked

Events

event Locked(address indexed account, uint256 value);

ERC20MintingConnector

Git Source

Inherits: ConnectorUpgradeableBase, Receiver, ERC20MintingConnectorLogic

Functions

initialize

function initialize(BridgeBase _bridge, IERC20MintableBurnable _token, address token_on_other_network) public initializer;

ERC20MintingConnectorLogic

Git Source

Inherits: TokenConnectorLogic

Functions

applyState

Applies the given state to the token contract by transfers.

function applyState(bytes calldata _state) public virtual override onlyBridge;

Parameters

NameTypeDescription
_statebytesThe state to be applied.

burn

The amount of tokens to burn must be approved by the sender

Burns a specified amount of tokens to transfer them to the other network.

function burn(uint256 value) public payable onlySettled;

Parameters

NameTypeDescription
valueuint256The amount of tokens to burn

Events

Burned

Events

event Burned(address indexed account, uint256 value);

IBridgeConnector

Git Source

Interface for bridgeable contracts.

Functions

finalize

Finalizes the bridge operation and returns a bytes32 value hash.

function finalize(uint256 epoch) external returns (bytes32 finalizedHash);

Parameters

NameTypeDescription
epochuint256The epoch to be finalized

Returns

NameTypeDescription
finalizedHashbytes32of the finalized state

applyState

Applies the given state to the bridgeable contract.

function applyState(bytes calldata _state) external;

Parameters

NameTypeDescription
_statebytesThe state to apply.

isStateEmpty

Checks if the state is empty.

function isStateEmpty() external view returns (bool);

Returns

NameTypeDescription
<none>booltrue if the state is empty, false otherwise

getFinalizedState

Retrieves the finalized state of the bridgeable contract.

function getFinalizedState() external view returns (bytes memory);

Returns

NameTypeDescription
<none>bytesA bytes serialized finalized state

getSourceContract

Returns the address of the underlying contract in this network

function getSourceContract() external view returns (address);

getDestinationContract

Returns the address of the bridged contract on the other network

function getDestinationContract() external view returns (address);

getStateLength

Returns the length of the state entries

function getStateLength() external view returns (uint256);

IERC20MintableBurnable

Git Source

Inherits: IERC20

Functions

mintTo

Mints a specified amount of tokens and assigns them to the specified account.

function mintTo(address receiver, uint256 amount) external;

Parameters

NameTypeDescription
receiveraddressThe address to which the tokens will be minted.
amountuint256The amount of tokens to be minted.

burnFrom

*Destroys a value amount of tokens from account, deducting from the caller's allowance. See ERC20-_burn and {ERC20-allowance}. Requirements:

  • the caller must have allowance for accounts's tokens of at least value.*
function burnFrom(address account, uint256 value) external;

Parameters

NameTypeDescription
accountaddressThe address from which the tokens will be burnt.
valueuint256The amount of tokens to burn.

NativeConnector

Git Source

Inherits: ConnectorUpgradeableBase, Receiver, NativeConnectorLogic

Functions

initialize

function initialize(BridgeBase _bridge, address token_on_other_network) public initializer;

NativeConnectorLogic

Git Source

Inherits: TokenConnectorLogic

Functions

applyState

Applies the given state to the token contract by transfers.

function applyState(bytes calldata _state) public virtual override onlyBridge;

Parameters

NameTypeDescription
_statebytesThe state to be applied.

lock

This function is payable, meaning it can receive TARA.

Locks the specified amount of tokens to transfer them to the other network.

function lock(uint256 amount) public payable;

Events

Locked

Events

event Locked(address indexed account, uint256 value);

TokenConnectorLogic

Git Source

Inherits: IBridgeConnector

State Variables

bridge

BridgeBase public bridge;

token

address public token;

otherNetworkAddress

address public otherNetworkAddress;

state

TokenState public state;

finalizedState

bytes public finalizedState;

Functions

onlySettled

modifier onlySettled();

onlyBridge

modifier onlyBridge();

estimateSettlementFee

function estimateSettlementFee(address locker) public view returns (uint256);

epoch

function epoch() public view returns (uint256);

decodeTransfers

function decodeTransfers(bytes memory data) internal pure returns (Transfer[] memory);

isStateEmpty

function isStateEmpty() external view override returns (bool);

getStateLength

function getStateLength() external view returns (uint256);

finalize

function finalize(uint256 epoch_to_finalize) public virtual override onlyBridge returns (bytes32);

getFinalizedState

Retrieves the finalized state of the bridgeable contract.

function getFinalizedState() public view override returns (bytes memory);

Returns

NameTypeDescription
<none>bytesA bytes serialized finalized state

getSourceContract

Returns the address of the underlying contract in this network

function getSourceContract() external view returns (address);

getDestinationContract

Returns the address of the bridged contract on the other network

function getDestinationContract() external view returns (address);

applyState

function applyState(bytes calldata) external virtual;

Events

Finalized

Events

event Finalized(uint256 indexed epoch);

AssetBridged

event AssetBridged(address indexed connector, address indexed account, uint256 value);

Transfer

Git Source

struct Transfer { address account; uint256 amount; }

TokenState

Git Source

Inherits: Ownable

State Variables

epoch

uint256 public epoch;

accounts

address[] public accounts;

balances

mapping(address => uint256) public balances;

Functions

constructor

constructor(uint256 _epoch) Ownable(msg.sender);

hasBalance

function hasBalance(address account) public view returns (bool);

empty

function empty() public view returns (bool);

getStateLength

function getStateLength() public view returns (uint256);

setEpoch

function setEpoch(uint256 _epoch) public onlyOwner;

addAmount

function addAmount(address account, uint256 amount) public onlyOwner;

getTransfers

function getTransfers() public view returns (Transfer[] memory);

cleanup

function cleanup() public onlyOwner;

Events

TransferAdded

Events

event TransferAdded(address indexed account, uint256 amount);

USDTMintingConnector

Git Source

Inherits: ConnectorUpgradeableBase, Receiver, USDTMintingConnectorLogic

Functions

initialize

function initialize(BridgeBase _bridge, IERC20MintableBurnable _token, address token_on_other_network) public initializer;

USDTMintingConnectorLogic

Git Source

Inherits: TokenConnectorLogic

Functions

applyState

Applies the given state to the token contract by transfers.

function applyState(bytes calldata _state) public virtual override onlyBridge;

Parameters

NameTypeDescription
_statebytesThe state to be applied.

burn

The amount of tokens to burn must be approved by the sender

Burns a specified amount of tokens to transfer them to the other network.

function burn(uint256 value) public payable onlySettled;

Parameters

NameTypeDescription
valueuint256The amount of tokens to burn

Events

Burned

Events

event Burned(address indexed account, uint256 value);

Contents

StateNotMatchingBridgeRoot

Git Source

error StateNotMatchingBridgeRoot(bytes32 stateRoot, bytes32 bridgeRoot);

ConnectorAlreadyRegistered

Git Source

error ConnectorAlreadyRegistered(address connector, address token);

NotSuccessiveEpochs

Git Source

error NotSuccessiveEpochs(uint256 epoch, uint256 nextEpoch);

NotEnoughBlocksPassed

Git Source

error NotEnoughBlocksPassed(uint256 lastFinalizedBlock, uint256 currentInterval, uint256 requiredInterval);

InvalidStateHash

Git Source

error InvalidStateHash(bytes32 stateHash, bytes32 expectedStateHash);

InvalidBridgeRoot

Git Source

error InvalidBridgeRoot(bytes32 bridgeRoot);

ZeroAddress

Git Source

error ZeroAddress(string message);

ZeroAddressCannotBeRegistered

Git Source

error ZeroAddressCannotBeRegistered();

NoStateToFinalize

Git Source

error NoStateToFinalize();

IncorrectOwner

Git Source

error IncorrectOwner(address owner, address expected);

HashesNotMatching

Git Source

error HashesNotMatching(bytes32 expected, bytes32 actual);

InvalidBlockInterval

Git Source

error InvalidBlockInterval(uint256 expected, uint256 actual);

InvalidEpoch

Git Source

error InvalidEpoch(uint256 expected, uint256 actual);

ThresholdNotMet

Git Source

error ThresholdNotMet(uint256 threshold, uint256 weight);

DuplicateSignatures

Git Source

error DuplicateSignatures(address author);

SignaturesNotSorted

Git Source

error SignaturesNotSorted();

InsufficientFunds

Git Source

error InsufficientFunds(uint256 expected, uint256 actual);

TransferFailed

Git Source

error TransferFailed(address target, uint256 amount);

InvalidEpoch

Git Source

error InvalidEpoch(uint256 expected, uint256 actual);

NotBridge

Git Source

error NotBridge(address sender);

NoFinalizedState

Git Source

error NoFinalizedState();

ZeroValueCall

Git Source

error ZeroValueCall();

Contents

EthBridge

Git Source

Inherits: BridgeBase

Functions

initialize

function initialize( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) public initializer;

__initialize_EthBridge_unchained

function __initialize_EthBridge_unchained( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) internal onlyInitializing;

TaraClient

Git Source

Inherits: IBridgeLightClient, OwnableUpgradeable, UUPSUpgradeable

State Variables

finalized

Contains the last finalized block

PillarBlock.FinalizedBlock public finalized;

finalizedBridgeRoots

Contains the last finalized block for each epoch

mapping(uint256 => bytes32) public finalizedBridgeRoots;

validatorVoteCounts

mapping(address => uint256) public validatorVoteCounts;

totalWeight

uint256 public totalWeight;

pillarBlockInterval

uint256 public pillarBlockInterval;

__gap

gap for upgrade safety <- can be used to add new storage variables(using up to 49 32 byte slots) in new versions of this contract If used, decrease the number of slots in the next contract that inherits this one(ex. uint256[48] __gap;)

uint256[49] __gap;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

initialize

function initialize(uint256 _pillarBlockInterval) public initializer;

__TaraClient_init_unchained

function __TaraClient_init_unchained(uint256 _pillarBlockInterval) internal onlyInitializing;

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal override onlyOwner;

getFinalized

function getFinalized() public view returns (PillarBlock.FinalizedBlock memory);

getFinalizedBridgeRoot

Returns the finalized bridge root.

function getFinalizedBridgeRoot(uint256 epoch) external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The finalized bridge root as a bytes32 value.

processValidatorChanges

Processes the changes in validator weights.

function processValidatorChanges(PillarBlock.VoteCountChange[] memory validatorChanges) internal;

Parameters

NameTypeDescription
validatorChangesPillarBlock.VoteCountChange[]An array of VoteCountChange structs representing the changes in validator vote counts.

finalizeBlocks

Finalizes blocks by verifying the signatures for the last blocks

function finalizeBlocks(PillarBlock.WithChanges[] memory blocks, CompactSignature[] memory lastBlockSigs) public;

Parameters

NameTypeDescription
blocksPillarBlock.WithChanges[]list of PillarBlockWithChanges.
lastBlockSigsCompactSignature[]An array of Signature structs representing the signatures of the last block.

getSignaturesWeight

Calculates the total weight of the signatures

function getSignaturesWeight(bytes32 h, CompactSignature[] memory signatures) public view returns (uint256 weight);

Parameters

NameTypeDescription
hbytes32The hash for verification.
signaturesCompactSignature[]An array of signatures.

Returns

NameTypeDescription
weightuint256The total weight of the signatures.

Events

BlockFinalized

Events

event BlockFinalized(PillarBlock.FinalizedBlock indexed finalized);

Contents

BridgeBase

Git Source

Inherits: Receiver, OwnableUpgradeable, UUPSUpgradeable

State Variables

connectors

Mapping of connectors to the token address

mapping(address => IBridgeConnector) public connectors;

localAddress

Mapping of source and destination addresses to the connector address

mapping(address => address) public localAddress;

bridgeRoots

The bridge roots of finalized epochs

mapping(uint256 => bytes32) public bridgeRoots;

lightClient

The light client used to get the finalized bridge root

IBridgeLightClient public lightClient;

tokenAddresses

The addresses of the registered tokens

address[] public tokenAddresses;

finalizedEpoch

The epoch of the last finalized epoch

uint256 public finalizedEpoch;

appliedEpoch

The epoch of the last applied epoch

uint256 public appliedEpoch;

finalizationInterval

The interval between epoch finalizations

uint256 public finalizationInterval;

lastFinalizedBlock

The block number of the last finalized epoch

uint256 public lastFinalizedBlock;

feeMultiplierFinalize

This multiplier is used to calculate the proper part of the relaying cost for bridging actions(state finalization)

uint256 public feeMultiplierFinalize;

feeMultiplierApply

This multiplier is used to calculate the proper part of the relaying cost for bridging actions(state application)

uint256 public feeMultiplierApply;

registrationFee

Global connector registration fee. Connectors must pay this fee to register

uint256 public registrationFee;

settlementFee

Global transaction settlement fee. Connector must pay settlementFee * numberOfTransactions to settle the transaction

uint256 public settlementFee;

__gap

gap for upgrade safety <- can be used to add new storage variables(using up to 49 32 byte slots) in new versions of this contract If used, decrease the number of slots in the next contract that inherits this one(ex. uint256[48] __gap;)

uint256[49] __gap;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

__BridgeBase_init

function __BridgeBase_init( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) internal onlyInitializing;

__BridgeBase_init_unchained

function __BridgeBase_init_unchained( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) internal onlyInitializing;

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal override onlyOwner;

setFeeMultiplierFinalize

Only the owner can call this function.

Sets the fee multiplier for finalizing epochs.

function setFeeMultiplierFinalize(uint256 _feeMultiplierFinalize) public onlyOwner;

Parameters

NameTypeDescription
_feeMultiplierFinalizeuint256The fee multiplier for finalizing epochs.

setFeeMultiplierApply

Only the owner can call this function.

Sets the fee multiplier for applying epochs.

function setFeeMultiplierApply(uint256 _feeMultiplierApply) public onlyOwner;

Parameters

NameTypeDescription
_feeMultiplierApplyuint256The fee multiplier for applying epochs.

setSettlementFee

Only the owner can call this function.

Sets the settlement fee.

function setSettlementFee(uint256 _settlementFee) public onlyOwner;

Parameters

NameTypeDescription
_settlementFeeuint256The settlement fee to be set.

setFinalizationInterval

Only the owner can call this function.

Sets the finalization interval.

function setFinalizationInterval(uint256 _finalizationInterval) public onlyOwner;

Parameters

NameTypeDescription
_finalizationIntervaluint256The finalization interval to be set.

setLightClient

Only the owner can call this function.

Sets the light client.

function setLightClient(IBridgeLightClient _lightClient) public onlyOwner;

Parameters

NameTypeDescription
_lightClientIBridgeLightClientThe address of the light client contract.

setConnectorOwner

Only the owner can call this function.

Changes the connector owner.

function setConnectorOwner(address connector_address, address newOwner) public onlyOwner;

Parameters

NameTypeDescription
connector_addressaddressThe connector address.
newOwneraddressThe new owner address.

removeConnector

Only the owner can call this function.

Removes a connector from the bridge.

function removeConnector(address connector_address) public onlyOwner;

Parameters

NameTypeDescription
connector_addressaddressThe connector address.

withdrawFunds

Only the owner can call this function.

Withdraws the funds from the contract.

function withdrawFunds() public onlyOwner;

registeredTokens

function registeredTokens() public view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]An array of addresses of the registered tokens.

getBridgeRoot

Gets the bridge root for the given epoch.

function getBridgeRoot(uint256 epoch) public view returns (bytes32);

Parameters

NameTypeDescription
epochuint256The epoch for which the bridge root is to be retrieved.

Returns

NameTypeDescription
<none>bytes32The bridge root as a bytes32 value.

getBridgeRoot

Returns the latest bridge root.

DO NOT REMOVE! Is used by the node to put it to the pillar block

function getBridgeRoot() public view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The latest bridge root as a bytes32 value.

registerConnector

Registers a contract with the EthBridge by providing a connector contract.

function registerConnector(IBridgeConnector connector) public payable;

Parameters

NameTypeDescription
connectorIBridgeConnectorThe address of the connector contract.

removeTokenAddress

function removeTokenAddress(address tokenAddress) internal;

delistConnector

function delistConnector(IBridgeConnector connector) internal;

applyState

Applies the given state with proof to the contracts.

function applyState(SharedStructs.StateWithProof calldata state_with_proof) public;

Parameters

NameTypeDescription
state_with_proofSharedStructs.StateWithProofThe state with proof to be applied.

shouldFinalizeEpoch

Checks whether the current epoch should be finalized.

DO NOT REMOVE! Is used by the node to identify if we need to call a finalization

function shouldFinalizeEpoch() public view returns (bool);

Returns

NameTypeDescription
<none>boolA boolean value indicating whether the current epoch should be finalized.

finalizeEpoch

Finalizes the current epoch.

function finalizeEpoch() public;

getStateWithProof

function getStateWithProof() public view returns (SharedStructs.StateWithProof memory ret);

Returns

NameTypeDescription
retSharedStructs.StateWithProoffinalized states with proof for all tokens

Events

Finalized

Events

event Finalized(uint256 indexed epoch, bytes32 bridgeRoot);

ConnectorRegistered

event ConnectorRegistered(address indexed connector, address indexed token_source, address indexed token_destination);

ConnectorDelisted

event ConnectorDelisted(address indexed connector, uint256 indexed epoch);

BridgeUSDT

Git Source

Inherits: ERC20

Functions

constructor

constructor() ERC20("BridgeUSDT", "USDT");

decimals

function decimals() public pure override returns (uint8);

CompactSignature

Git Source

struct CompactSignature { bytes32 r; bytes32 vs; }

Constants

Git Source

State Variables

NATIVE_TOKEN_ADDRESS

address public constant NATIVE_TOKEN_ADDRESS = address(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);

MINIMUM_CONNECTOR_DEPOSIT

uint256 public constant MINIMUM_CONNECTOR_DEPOSIT = 0.001 ether;

IBridgeLightClient

Git Source

Functions

getFinalizedBridgeRoot

function getFinalizedBridgeRoot(uint256 epoch) external view returns (bytes32);

Maths

Git Source

Functions

add

function add(uint256 a, int256 b) internal pure returns (uint256);

PillarBlock

Git Source

Functions

fromBytes

function fromBytes(bytes memory b) internal pure returns (WithChanges memory);

getHash

function getHash(bytes memory b) internal pure returns (bytes32);

getHash

function getHash(WithChanges memory b) internal pure returns (bytes32);

getHash

function getHash(Vote memory b) internal pure returns (bytes32);

getHash

function getHash(SignedVote memory b) internal pure returns (bytes32);

getVoteHash

function getVoteHash(WithChanges memory b) internal pure returns (bytes32);

getVoteHash

function getVoteHash(uint256 period, bytes32 bh) internal pure returns (bytes32);

Structs

VoteCountChange

Vote count change coming from a validator Encapsulates the address of the validator and the vote count of the validator vote(signature)

struct VoteCountChange { address validator; int32 change; }

FinalizationData

struct FinalizationData { uint256 period; bytes32 stateRoot; bytes32 prevHash; bytes32 bridgeRoot; uint256 epoch; }

WithChanges

struct WithChanges { FinalizationData block; VoteCountChange[] validatorChanges; }

FinalizedBlock

struct FinalizedBlock { bytes32 blockHash; FinalizationData block; uint256 finalizedAt; }

Vote

struct Vote { uint256 period; bytes32 block_hash; }

SignedVote

struct SignedVote { Vote vote; CompactSignature signature; }

Receiver

Git Source

Functions

receive

receive() external payable;

SharedStructs

Git Source

Functions

getBridgeRoot

function getBridgeRoot(uint256 epoch, ContractStateHash[] memory state_hashes) internal pure returns (bytes32);

Structs

StateWithAddress

struct StateWithAddress { address contractAddress; bytes state; }

ContractStateHash

struct ContractStateHash { address contractAddress; bytes32 stateHash; }

BridgeState

struct BridgeState { uint256 epoch; StateWithAddress[] states; }

StateWithProof

struct StateWithProof { BridgeState state; ContractStateHash[] state_hashes; }

TestERC20

Git Source

Inherits: ERC20, Ownable, IERC20MintableBurnable

Functions

constructor

constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) Ownable(msg.sender);

mintTo

Mints a specified amount of tokens and assigns them to the specified account.

function mintTo(address receiver, uint256 amount) public onlyOwner;

Parameters

NameTypeDescription
receiveraddressThe address to which the tokens will be minted.
amountuint256The amount of tokens to be minted.

burnFrom

*Destroys a value amount of tokens from account, deducting from the caller's allowance. See ERC20-_burn and {ERC20-allowance}. Requirements:

  • the caller must have allowance for accounts's tokens of at least value.*
function burnFrom(address account, uint256 value) public virtual onlyOwner;

USDT

Git Source

Inherits: ERC20, Ownable, IERC20MintableBurnable

Functions

constructor

constructor() ERC20("Tether USD", "USDT") Ownable(msg.sender);

decimals

function decimals() public pure override returns (uint8);

mintTo

Mints a specified amount of tokens and assigns them to the specified account.

function mintTo(address receiver, uint256 amount) public onlyOwner;

Parameters

NameTypeDescription
receiveraddressThe address to which the tokens will be minted.
amountuint256The amount of tokens to be minted.

burnFrom

*Destroys a value amount of tokens from account, deducting from the caller's allowance. See ERC20-_burn and {ERC20-allowance}. Requirements:

  • the caller must have allowance for accounts's tokens of at least value.*
function burnFrom(address account, uint256 value) public virtual onlyOwner;

Contents

EthClient

Git Source

Inherits: IBridgeLightClient, OwnableUpgradeable, UUPSUpgradeable

State Variables

client

BeaconLightClient public client;

ethBridgeAddress

address public ethBridgeAddress;

bridgeRootsMappingPosition

bytes32 public bridgeRootsMappingPosition;

lastEpoch

uint256 public lastEpoch;

bridgeRoots

mapping(uint256 => bytes32) public bridgeRoots;

__gap

gap for upgrade safety <- can be used to add new storage variables(using up to 49 32 byte slots) in new versions of this contract If used, decrease the number of slots in the next contract that inherits this one(ex. uint256[48] __gap;)

uint256[49] __gap;

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

initialize

function initialize(BeaconLightClient _client, address _eth_bridge_address) public initializer;

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal override onlyOwner;

setBeaconLightClient

Sets the BeaconLightClient instance.

function setBeaconLightClient(BeaconLightClient _client) external onlyOwner;

Parameters

NameTypeDescription
_clientBeaconLightClientThe address of the new BeaconLightClient contract.

getFinalizedBridgeRoot

Implements the IBridgeLightClient interface method

function getFinalizedBridgeRoot(uint256 epoch) external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The finalized bridge root as a bytes32 value.

bridgeRootKeyByEpoch

function bridgeRootKeyByEpoch(uint256 epoch) public view returns (bytes32);

processBridgeRoot

Processes the bridge root by verifying account and storage proofs against state root from the light client.

function processBridgeRoot(bytes[] memory account_proof, bytes[] memory storage_proof) external;

Parameters

NameTypeDescription
account_proofbytes[]The account proofs for the bridge root.
storage_proofbytes[]The storage proofs for the bridge root.

getMerkleRoot

Returns the Merkle root from the light client.

function getMerkleRoot() external view returns (bytes32);

Returns

NameTypeDescription
<none>bytes32The Merkle root as a bytes32 value.

Events

BridgeRootProcessed

Events

event BridgeRootProcessed(bytes32 indexed bridgeRoot);

TaraBridge

Git Source

Inherits: BridgeBase

Functions

initialize

function initialize( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) public initializer;

__initialize_EthBridge_unchained

function __initialize_EthBridge_unchained( IBridgeLightClient _lightClient, uint256 _finalizationInterval, uint256 _feeMultiplierFinalize, uint256 _feeMultiplierApply, uint256 _registrationFee, uint256 _settlementFee ) internal onlyInitializing;