Contract 0x841ce48f9446c8e281d3f1444cb859b4a6d0738c 7

 
Ad
Ad
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x414e0c8728d7735acd526f9deed0ad24aee8aca2492955061d82ffaec7ce4bbdConfirm202997732021-10-17 4:08:331 min ago0xf97c77c4a036752854663ca597f097aa5db7534b IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00206835
0x84a6483f0c9b397a009db72efce3c08ee370d05cc1ed4f04d4a47025b1edf9d8Transfer In202997472021-10-17 4:07:412 mins ago0xc16251b5401087902e0956a2968cb3e0e4a52760 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01585712
0x125702ba42a55e20d5e63e413f23d772d74385d56c37c75c7b1a8384f42ccb4bConfirm202996482021-10-17 4:02:137 mins ago0x9f55dad1f896b24cea3c93dabc9b37a6dbb29eb8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0068945
0xbcc4b2b23b4f16a958748c84cb18df784bea5e3a7c8828c67b1c6132a3285fe9Transfer Out202996292021-10-17 4:01:298 mins ago0xf97c77c4a036752854663ca597f097aa5db7534b IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00549279
0x547dc3409fe1ce534efefd70c88a38c9d6c9217a5fb8ff33c770d0793a662379Confirm202996032021-10-17 4:00:379 mins ago0x654a9165ed4180185e7e0d080b559e5cc5b7cb40 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00206835
0x52dc9700c40469b238d370da275b678686b8a105667a4fc07391d7b3301423eeConfirm202995822021-10-17 3:59:5110 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00458712
0x0c13658a8ac19037f708f27c2ce1c77ebb14b05130f2ab7a511fe0e064ab9ea4Transfer Out202995312021-10-17 3:58:0911 mins ago0x9f55dad1f896b24cea3c93dabc9b37a6dbb29eb8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0198093
0xe13149f14c05029ebbb361e8a5d40bb8fecffc1faecc7bea2d223faed490f566Confirm202995202021-10-17 3:57:4712 mins ago0x76264a50875edd1f42ccedbdf21f63cf1286a0c1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00638392
0xce32ae28ede6bbfea68443474e747e33116f312779cdc52e996211963a383f99Transfer Out202994532021-10-17 3:55:1714 mins ago0x654a9165ed4180185e7e0d080b559e5cc5b7cb40 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00549315
0x2076b04949764fbdc5ba6032fe1dede6dd85af23a09bebd2b3efc52297474397Transfer In202994042021-10-17 3:50:2319 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01491216
0xf47ff0dca66ed3673e3cae63d2616336d232349ccf1d831b816f9f315b3ffebbConfirm202994002021-10-17 3:49:5920 mins ago0x40f87ae5b29220fc05847b78c4f37a32ac55a20c IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00206835
0x8dcfb0128435198565255cb4102ae46b287a4be6cd4ea813a2411ccb039bb7a0Confirm202993732021-10-17 3:48:2521 mins ago0x9f55dad1f896b24cea3c93dabc9b37a6dbb29eb8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0068945
0x6b97320dc9285aeef63b59caaae96a7e0a8d155128d63ab2b0079efcca1b2237Transfer In202993422021-10-17 3:47:2322 mins ago0x76264a50875edd1f42ccedbdf21f63cf1286a0c1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01533584
0x5b7eea01ad7d4b9d3c7b202dcda90213d4237931ef35268290e9b48efa7486ddTransfer Out202992722021-10-17 3:44:5925 mins ago0x40f87ae5b29220fc05847b78c4f37a32ac55a20c IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00549315
0xd47a150f1da4ae3a2f35ed7794b3f79a7a7de4dca1e448632588d37d2d8bbc1cConfirm202992552021-10-17 3:44:2125 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00595512
0x74a482f421a8577585a72dc3a02159546c6bdacb899393d6d0073884948536bbTransfer Out202992502021-10-17 3:44:1125 mins ago0x9f55dad1f896b24cea3c93dabc9b37a6dbb29eb8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0198081
0xa0029f3e078e3d4ae6b2f0b5bda3bca39a5bec2204b071b648658a375158331fConfirm202991372021-10-17 3:40:2129 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.004164080195
0x1e554492418a9bec42eb9293d8fea58f0a8c33ac71dc420c488dc70045f969d6Confirm202991292021-10-17 3:40:0130 mins ago0xc16251b5401087902e0956a2968cb3e0e4a52760 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.004161784183
0xe5697cedd50ecf801abbd77d16be2b6e0773b4c348c937c5d14407fab871461fTransfer In202991002021-10-17 3:39:0331 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01025145
0x3c5e4fdad47baacd40fdc60a34c5a561b92fee38cff04da27267ddf73e668a84Confirm202990542021-10-17 3:36:5333 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0068836
0xfdc01ba1705457014e30bc682ac55c90d54d86530a9c5154cfecccfdb03a0c1dTransfer Out202990532021-10-17 3:36:4933 mins ago0x154d78cbadc756411f7fbb7f463bac5c6343af0e IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00594315
0x71c0ea6ab17dcb22a8354e438ac829703a6f46240e691f817278834078c798adConfirm202990442021-10-17 3:36:1333 mins ago0xbf1311ad8b91b72705658fbab06b3f9d3c4cded8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.00638392
0x139610850cd09929728669ae0795e81d811b3338275bd4fb87aa9323b4f4ad43Confirm202990312021-10-17 3:35:2134 mins ago0x9f55dad1f896b24cea3c93dabc9b37a6dbb29eb8 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.0068945
0x56ea8168ca4e4c5bddaade5651b755f122024942a80d4e7e8397ec36ba361608Transfer In202990212021-10-17 3:34:4135 mins ago0xc16251b5401087902e0956a2968cb3e0e4a52760 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01534768
0xa21a06bd29479a0b234da522bf8e9f720a61b742ced3d816a291b37316b53bb9Transfer In202989972021-10-17 3:33:2136 mins ago0xc75a0ff40db54203d66bff76315ed25d66037ce1 IN  0x841ce48f9446c8e281d3f1444cb859b4a6d0738c0 MATIC0.01533488
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CBridge

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 4 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 2 of 4 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 3 of 4 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain`call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
      return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 4 of 4 : CBridge.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;
pragma abicoder v2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract CBridge {
    using SafeERC20 for IERC20;

    enum TransferStatus {Null, Pending, Confirmed, Refunded}
    struct Transfer {
        address sender;
        address receiver;
        address token;
        uint256 amount;
        bytes32 hashlock; // hash of the preimage
        uint64 timelock; // UNIX timestamp seconds - locked UNTIL this time
        TransferStatus status;
    }

    mapping(bytes32 => Transfer) public transfers;

    event LogNewTransferOut(
        bytes32 transferId,
        address sender,
        address receiver,
        address token,
        uint256 amount,
        bytes32 hashlock, // hash of the preimage
        uint64 timelock, // UNIX timestamp seconds - locked UNTIL this time
        uint64 dstChainId,
        address dstAddress
    );
    event LogNewTransferIn(
        bytes32 transferId,
        address sender,
        address receiver,
        address token,
        uint256 amount,
        bytes32 hashlock, // hash of the preimage
        uint64 timelock, // UNIX timestamp seconds - locked UNTIL this time
        uint64 srcChainId,
        bytes32 srcTransferId // outbound transferId at src chain
    );
    event LogTransferConfirmed(bytes32 transferId, bytes32 preimage);
    event LogTransferRefunded(bytes32 transferId);

    /**
     * @dev transfer sets up a new outbound transfer with hash time lock.
     */
    function transferOut(
        address _bridge,
        address _token,
        uint256 _amount,
        bytes32 _hashlock,
        uint64 _timelock,
        uint64 _dstChainId,
        address _dstAddress
    ) external {
        bytes32 transferId = _transfer(_bridge, _token, _amount, _hashlock, _timelock);
        emit LogNewTransferOut(transferId, msg.sender, _bridge, _token, _amount, _hashlock, _timelock, _dstChainId, _dstAddress);
    }

    /**
     * @dev transfer sets up a new inbound transfer with hash time lock.
     */
    function transferIn(
        address _dstAddress,
        address _token,
        uint256 _amount,
        bytes32 _hashlock,
        uint64 _timelock,
        uint64 _srcChainId,
        bytes32 _srcTransferId
    ) external {
        bytes32 transferId = _transfer(_dstAddress, _token, _amount, _hashlock, _timelock);
        emit LogNewTransferIn(transferId, msg.sender, _dstAddress, _token, _amount, _hashlock, _timelock, _srcChainId, _srcTransferId);
    }

    /**
     * @dev confirm a transfer.
     *
     * @param _transferId Id of pending transfer.
     * @param _preimage key for the hashlock
     */
    function confirm(bytes32 _transferId, bytes32 _preimage) external {
        Transfer memory t = transfers[_transferId];

        require(t.status == TransferStatus.Pending, "not pending transfer");
        require(t.hashlock == keccak256(abi.encodePacked(_preimage)), "incorrect preimage");

        transfers[_transferId].status = TransferStatus.Confirmed;

        IERC20(t.token).safeTransfer(t.receiver, t.amount);
        emit LogTransferConfirmed(_transferId, _preimage);
    }

    /**
     * @dev refund a transfer after timeout.
     *
     * @param _transferId Id of pending transfer.
     */
    function refund(bytes32 _transferId) external {
        Transfer memory t = transfers[_transferId];

        require(t.status == TransferStatus.Pending, "not pending transfer");
        require(t.timelock <= block.timestamp, "timelock not yet passed");

        transfers[_transferId].status = TransferStatus.Refunded;

        IERC20(t.token).safeTransfer(t.sender, t.amount);
        emit LogTransferRefunded(_transferId);
    }


    /**
     * @dev transfer sets up a new transfer with hash time lock.
     */
    function _transfer(
        address _receiver,
        address _token,
        uint256 _amount,
        bytes32 _hashlock,
        uint64 _timelock
    ) private returns (bytes32 transferId) {
        require(_amount > 0, "invalid amount");
        require(_timelock > block.timestamp, "invalid timelock");

        transferId = keccak256(abi.encodePacked(msg.sender, _receiver, _hashlock, block.chainid));
        require(transfers[transferId].status == TransferStatus.Null, "transfer exists");

        IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);

        transfers[transferId] = Transfer(
            msg.sender,
            _receiver,
            _token,
            _amount,
            _hashlock,
            _timelock,
            TransferStatus.Pending
        );
        return transferId;
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transferId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"timelock","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"srcChainId","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"srcTransferId","type":"bytes32"}],"name":"LogNewTransferIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transferId","type":"bytes32"},{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"timelock","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"dstChainId","type":"uint64"},{"indexed":false,"internalType":"address","name":"dstAddress","type":"address"}],"name":"LogNewTransferOut","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transferId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"preimage","type":"bytes32"}],"name":"LogTransferConfirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"transferId","type":"bytes32"}],"name":"LogTransferRefunded","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_transferId","type":"bytes32"},{"internalType":"bytes32","name":"_preimage","type":"bytes32"}],"name":"confirm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transferId","type":"bytes32"}],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dstAddress","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32","name":"_hashlock","type":"bytes32"},{"internalType":"uint64","name":"_timelock","type":"uint64"},{"internalType":"uint64","name":"_srcChainId","type":"uint64"},{"internalType":"bytes32","name":"_srcTransferId","type":"bytes32"}],"name":"transferIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bridge","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32","name":"_hashlock","type":"bytes32"},{"internalType":"uint64","name":"_timelock","type":"uint64"},{"internalType":"uint64","name":"_dstChainId","type":"uint64"},{"internalType":"address","name":"_dstAddress","type":"address"}],"name":"transferOut","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"transfers","outputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32","name":"hashlock","type":"bytes32"},{"internalType":"uint64","name":"timelock","type":"uint64"},{"internalType":"enum CBridge.TransferStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50610fa8806100206000396000f3fe608060405234801561001057600080fd5b50600436106100675760003560e01c806357f784ba1161005057806357f784ba146101045780637249fbb614610117578063f63eba251461012a57600080fd5b80633c64f04b1461006c57806346b40027146100ef575b600080fd5b6100d361007a366004610e50565b6000602081905290815260409020805460018201546002830154600384015460048501546005909501546001600160a01b03948516959385169490921692909167ffffffffffffffff811690600160401b900460ff1687565b6040516100e69796959493929190610ea5565b60405180910390f35b6101026100fd366004610d49565b61013d565b005b610102610112366004610e68565b6101de565b610102610125366004610e50565b610417565b610102610138366004610dc0565b61062d565b600061014c88888888886106bf565b604080518281523360208201526001600160a01b03808c1692820192909252818a1660608201526080810189905260a0810188905267ffffffffffffffff80881660c0830152861660e08201529084166101008201529091507f2991ed59ec037d5602bdc81fb1f3fec360f9e68fd3c1a4efb49fb3f66a88e02190610120015b60405180910390a15050505050505050565b600082815260208181526040808320815160e08101835281546001600160a01b0390811682526001830154811694820194909452600282015490931691830191909152600380820154606084015260048201546080840152600582015467ffffffffffffffff811660a085015260c0840191600160401b90910460ff169081111561027957634e487b7160e01b600052602160045260246000fd5b600381111561029857634e487b7160e01b600052602160045260246000fd5b905250905060018160c0015160038111156102c357634e487b7160e01b600052602160045260246000fd5b146103155760405162461bcd60e51b815260206004820152601460248201527f6e6f742070656e64696e67207472616e7366657200000000000000000000000060448201526064015b60405180910390fd5b604080516020810184905201604051602081830303815290604052805190602001208160800151146103895760405162461bcd60e51b815260206004820152601260248201527f696e636f727265637420707265696d6167650000000000000000000000000000604482015260640161030c565b60008381526020818152604091829020600501805468ff00000000000000001916680200000000000000001790558201516060830151918301516103d9926001600160a01b0390911691906109cc565b60408051848152602081018490527fb7ae890c7a4721f7ed769dabfeee74f0e0f5bcdaad9cab432ccea4d9fa435b50910160405180910390a1505050565b600081815260208181526040808320815160e08101835281546001600160a01b0390811682526001830154811694820194909452600282015490931691830191909152600380820154606084015260048201546080840152600582015467ffffffffffffffff811660a085015260c0840191600160401b90910460ff16908111156104b257634e487b7160e01b600052602160045260246000fd5b60038111156104d157634e487b7160e01b600052602160045260246000fd5b905250905060018160c0015160038111156104fc57634e487b7160e01b600052602160045260246000fd5b146105495760405162461bcd60e51b815260206004820152601460248201527f6e6f742070656e64696e67207472616e73666572000000000000000000000000604482015260640161030c565b428160a0015167ffffffffffffffff1611156105a75760405162461bcd60e51b815260206004820152601760248201527f74696d656c6f636b206e6f742079657420706173736564000000000000000000604482015260640161030c565b60008281526020819052604090819020600501805468ff000000000000000019166803000000000000000017905581516060830151918301516105f6926001600160a01b0390911691906109cc565b6040518281527f70a8f332cabb778f79acc5b97cbb4543970a2f1a34bd0773e4b3012931f752dc9060200160405180910390a15050565b600061063c88888888886106bf565b604080518281523360208201526001600160a01b03808c169282019290925290891660608201526080810188905260a0810187905267ffffffffffffffff80871660c0830152851660e082015261010081018490529091507f252a438c8e02dde6c26723283b3c95b1bf2550b882734770523f1d6767636f9c90610120016101cc565b60008084116107105760405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420616d6f756e74000000000000000000000000000000000000604482015260640161030c565b428267ffffffffffffffff16116107695760405162461bcd60e51b815260206004820152601060248201527f696e76616c69642074696d656c6f636b00000000000000000000000000000000604482015260640161030c565b6040516bffffffffffffffffffffffff1933606090811b8216602084015288901b1660348201526048810184905246606882015260880160408051601f198184030181529190528051602090910120905060008082815260208190526040902060050154600160401b900460ff1660038111156107f657634e487b7160e01b600052602160045260246000fd5b146108435760405162461bcd60e51b815260206004820152600f60248201527f7472616e73666572206578697374730000000000000000000000000000000000604482015260640161030c565b6108586001600160a01b038616333087610a61565b6040518060e00160405280336001600160a01b03168152602001876001600160a01b03168152602001866001600160a01b031681526020018581526020018481526020018367ffffffffffffffff168152602001600160038111156108cd57634e487b7160e01b600052602160045260246000fd5b905260008281526020818152604091829020835181546001600160a01b039182167fffffffffffffffffffffffff000000000000000000000000000000000000000091821617835592850151600183018054918316918516919091179055928401516002820180549190941692169190911790915560608201516003808301919091556080830151600483015560a083015160058301805467ffffffffffffffff90921667ffffffffffffffff1983168117825560c086015193919268ffffffffffffffffff19161790600160401b9084908111156109bc57634e487b7160e01b600052602160045260246000fd5b0217905550505095945050505050565b6040516001600160a01b038316602482015260448101829052610a5c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610a9f565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610a999085906323b872dd60e01b906084016109f8565b50505050565b6000610af4826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b849092919063ffffffff16565b805190915015610a5c5780806020019051810190610b129190610e30565b610a5c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161030c565b6060610b938484600085610b9d565b90505b9392505050565b606082471015610c155760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161030c565b843b610c635760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161030c565b600080866001600160a01b03168587604051610c7f9190610e89565b60006040518083038185875af1925050503d8060008114610cbc576040519150601f19603f3d011682016040523d82523d6000602084013e610cc1565b606091505b5091509150610cd1828286610cdc565b979650505050505050565b60608315610ceb575081610b96565b825115610cfb5782518084602001fd5b8160405162461bcd60e51b815260040161030c9190610f13565b80356001600160a01b0381168114610d2c57600080fd5b919050565b803567ffffffffffffffff81168114610d2c57600080fd5b600080600080600080600060e0888a031215610d63578283fd5b610d6c88610d15565b9650610d7a60208901610d15565b95506040880135945060608801359350610d9660808901610d31565b9250610da460a08901610d31565b9150610db260c08901610d15565b905092959891949750929550565b600080600080600080600060e0888a031215610dda578283fd5b610de388610d15565b9650610df160208901610d15565b95506040880135945060608801359350610e0d60808901610d31565b9250610e1b60a08901610d31565b915060c0880135905092959891949750929550565b600060208284031215610e41578081fd5b81518015158114610b96578182fd5b600060208284031215610e61578081fd5b5035919050565b60008060408385031215610e7a578182fd5b50508035926020909101359150565b60008251610e9b818460208701610f46565b9190910192915050565b6001600160a01b038881168252878116602083015286166040820152606081018590526080810184905267ffffffffffffffff831660a082015260e0810160048310610f0157634e487b7160e01b600052602160045260246000fd5b8260c083015298975050505050505050565b6020815260008251806020840152610f32816040850160208701610f46565b601f01601f19169190910160400192915050565b60005b83811015610f61578181015183820152602001610f49565b83811115610a99575050600091015256fea26469706673582212203f576b683b544859852e2612f7dba9316d83a2b49a4f7764b07147c61931e03a64736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.