The core logic of the bridge is coded in convertFrom() and convertTo() functions of the contract.

convertFrom() is called from the bridge when it receives transaction to the TLO wallet with payment ID. Payment ID is decoded and used as destination ETH address. The decoding uses simple 6-bit table mapping 0-9, a-f and A-F, so checksum of the ETH address is preserved. The bridge will use owner address to pay the gas for the transaction.

convertTo() can be called from any ETH address with wTLO balance to convert back to TLO, it will require base58 decoded version of the TLO address as all contract function parameters are encoded in hexadecimal. Currently minimum convertible amount is 1.00 TLO and the token amount is subtracted by TLO network fee.

If other coins want to use the same contract, they must replace convertFrom() function with transfer() function using dedicated ETH address as substitute for the owner address of the contract. There is no 1-to-1 alternative for convertTo() function as it would require new contract method and event for each third-party coin. Because normal token transfer can’t specify metadata, the only viable solution is using decentralized exchange to swap wTLO to own wrapped token and then using function from that contract to convert back to own coin, or using dedicated swap contract holding balances in both tokens as intermediate.

Published by Mika

Lead developer and team leader of Talleo Project