Skip to main content

Solidity API

NativeTokenHandler

This contract is intended to be used with the Bridge contract.

constructor

constructor(address bridgeAddress) public
NameTypeDescription
bridgeAddressaddressContract address of previously deployed Bridge.

deposit

function deposit(bytes32 resourceID, address, bytes data) external payable returns (bytes)

A deposit is initiatied by making a deposit in the Bridge contract.

Requirements:

  • {tokenAddress} must be 0x01.
  • {tokenAddress} must be allowed.
  • {msg.value} must be equal to {amount}.
  • {amount} must be greater than 0.
  • Recipient address in data hex string must not be zero address.

Data passed into the function should be constructed as follows: amount uint256 bytes 0 - 32 destinationRecipientAddress length uint256 bytes 32 - 64 destinationRecipientAddress bytes bytes 64 - END

Depending if the corresponding {tokenAddress} for the parsed {resourceID} is marked true in {_burnList}, deposited tokens will be burned, if not, they will be locked.

NameTypeDescription
resourceIDbytes32ResourceID used to find address of token to be used for deposit.
address
databytesConsists of {amount} padded to 32 bytes.
NameTypeDescription
[0]bytesan empty data.

executeProposal

function executeProposal(bytes32 resourceID, bytes data) external

Proposal execution should be initiated when a proposal is finalized in the Bridge contract. by a relayer on the deposit's destination chain.

Requirements:

  • {tokenAddress} must be 0x01.
  • {tokenAddress} must be allowed.

Data passed into the function should be constructed as follows: amount uint256 bytes 0 - 32 destinationRecipientAddress length uint256 bytes 32 - 64 destinationRecipientAddress bytes bytes 64 - END

NameTypeDescription
resourceIDbytes32
databytesConsists of {resourceID}, {amount}, {lenDestinationRecipientAddress}, and {destinationRecipientAddress} all padded to 32 bytes.

safeTransferETH

function safeTransferETH(address to, uint256 value) internal

withdraw

function withdraw(bytes data) external

Used to manually release ERC20 tokens from ERC20Safe.

Requirements:

  • {tokenAddress} must be 0x01.

Data passed into the function should be constructed as follows: tokenAddress address bytes 0 - 32 recipient address bytes 32 - 64 amount uint bytes 64 - 96

NameTypeDescription
databytesConsists of {tokenAddress}, {recipient}, and {amount} all padded to 32 bytes.

_settle

function _settle(address tokenAddress, uint16, struct KeyValuePair[] entries) internal virtual

Requirements:

  • {tokenAddress} must be 0x01.
  • {tokenAddress} must be allowed.