ETH Price: $3,435.42 (+4.40%)

Contract

0xA5E38d098b54C00F10e32E51647086232a9A0afD
 
Transaction Hash
Method
Block
From
To
Redeem212493132024-11-23 8:42:115 hrs ago1732351331IN
0xA5E38d09...32a9A0afD
0 ETH0.0011241812.19724983
Initiate212493042024-11-23 8:40:235 hrs ago1732351223IN
0xA5E38d09...32a9A0afD
0 ETH0.0017514210.61828054
Redeem212491762024-11-23 8:14:475 hrs ago1732349687IN
0xA5E38d09...32a9A0afD
0 ETH0.0010668811.57560443
Initiate212491702024-11-23 8:13:355 hrs ago1732349615IN
0xA5E38d09...32a9A0afD
0 ETH0.001641669.95284268
Redeem212481142024-11-23 4:41:359 hrs ago1732336895IN
0xA5E38d09...32a9A0afD
0 ETH0.001058211.48291099
Initiate212481042024-11-23 4:39:359 hrs ago1732336775IN
0xA5E38d09...32a9A0afD
0 ETH0.001623419.84219534
Redeem212451442024-11-22 18:45:4719 hrs ago1732301147IN
0xA5E38d09...32a9A0afD
0 ETH0.0016373417.7649347
Initiate212451362024-11-22 18:44:1119 hrs ago1732301051IN
0xA5E38d09...32a9A0afD
0 ETH0.0027745916.82145708
Redeem212440712024-11-22 15:08:5922 hrs ago1732288139IN
0xA5E38d09...32a9A0afD
0 ETH0.0015533416.85354513
Initiate212440622024-11-22 15:07:1122 hrs ago1732288031IN
0xA5E38d09...32a9A0afD
0 ETH0.002586415.68050553
Redeem212398962024-11-22 1:09:5936 hrs ago1732237799IN
0xA5E38d09...32a9A0afD
0 ETH0.000904949.81851861
Initiate212398812024-11-22 1:06:5936 hrs ago1732237619IN
0xA5E38d09...32a9A0afD
0 ETH0.00159289.65663041
Redeem212394752024-11-21 23:45:1138 hrs ago1732232711IN
0xA5E38d09...32a9A0afD
0 ETH0.0012259213.30108685
Initiate212394682024-11-21 23:43:4738 hrs ago1732232627IN
0xA5E38d09...32a9A0afD
0 ETH0.002103612.75345208
Redeem212365392024-11-21 13:55:232 days ago1732197323IN
0xA5E38d09...32a9A0afD
0 ETH0.0027623429.97106919
Initiate212363832024-11-21 13:24:112 days ago1732195451IN
0xA5E38d09...32a9A0afD
0 ETH0.0057085334.61399125
Redeem212360132024-11-21 12:10:112 days ago1732191011IN
0xA5E38d09...32a9A0afD
0 ETH0.0018188324.22950081
Initiate212359782024-11-21 12:03:112 days ago1732190591IN
0xA5E38d09...32a9A0afD
0 ETH0.0024700115.90150835
Redeem212359622024-11-21 11:59:592 days ago1732190399IN
0xA5E38d09...32a9A0afD
0 ETH0.0008708911.60338307
Initiate212358962024-11-21 11:46:472 days ago1732189607IN
0xA5E38d09...32a9A0afD
0 ETH0.0027425116.62818225
Refund212356312024-11-21 10:52:592 days ago1732186379IN
0xA5E38d09...32a9A0afD
0 ETH0.0010880811.73036108
Redeem212355352024-11-21 10:33:352 days ago1732185215IN
0xA5E38d09...32a9A0afD
0 ETH0.0012919914.01793863
Initiate212355252024-11-21 10:31:352 days ago1732185095IN
0xA5E38d09...32a9A0afD
0 ETH0.002049512.42546453
Redeem212352012024-11-21 9:26:352 days ago1732181195IN
0xA5E38d09...32a9A0afD
0 ETH0.000704299.38224284
Initiate212350862024-11-21 9:03:232 days ago1732179803IN
0xA5E38d09...32a9A0afD
0 ETH0.0017198611.07134034
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AtomicSwap

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 5 : AtomicSwap.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;

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

/**
 * @author  Catalog
 * @title   HTLC smart contract for atomic swaps
 * @notice  Any signer can create an order to serve as one of either halfs of an cross chain
 *          atomic swap.
 * @dev     The contracts can be used to create an order to serve as the the commitment for two
 *          types of users :
 *          Initiator functions: 1. initate
 *                               2. refund
 *          Redeemer funtions: 1. redeem
 */

contract AtomicSwap {
    using SafeERC20 for IERC20;
    IERC20 public immutable token;

    struct Order {
        address redeemer;
        address initiator;
        uint256 expiry;
        uint256 initiatedAt;
        uint256 amount;
        bool isFulfilled;
    }
    mapping(bytes32 => Order) public atomicSwapOrders;

    event Redeemed(
        bytes32 indexed orderId,
        bytes32 indexed secrectHash,
        bytes secret
    );
    event Initiated(
        bytes32 indexed orderId,
        bytes32 indexed secretHash,
        uint256 initiatedAt,
        uint256 amount
    );
    event Refunded(bytes32 indexed orderId);

    /**
     * @notice  .
     * @dev     provides checks to ensure
     *              1. redeemer is not null address
     *              2. redeemer is not same as the refunder
     *              3. expiry is greater than current block number
     *              4. amount is not zero
     * @param   redeemer  public address of the reedeem
     * @param   intiator  public address of the initator
     * @param   expiry  expiry in period for the htlc order
     * @param   amount  amount of tokens to trade
     */
    modifier checkSafe(
        address redeemer,
        address intiator,
        uint256 expiry,
        uint256 amount
    ) {
        require(redeemer != address(0), "AtomicSwap: invalid redeemer address");
        require(
            intiator != redeemer,
            "AtomicSwap: redeemer and initiator cannot be the same"
        );
        require(expiry > 0, "AtomicSwap: expiry should be greater than zero");
        require(amount > 0, "AtomicSwap: amount cannot be zero");
        _;
    }

    constructor(address _token) {
        token = IERC20(_token);
    }

    /**
     * @notice  Signers can create an order with order params
     * @dev     Secret used to generate secret hash for iniatiation should be generated randomly
     *          and sha256 hash should be used to support hashing methods on other non-evm chains.
     *          Signers cannot generate orders with same secret hash or override an existing order.
     * @param   _redeemer  public address of the redeemer
     * @param   _expiry  expiry in period for the htlc order
     * @param   _amount  amount of tokens to trade
     * @param   _secretHash  sha256 hash of the secret used for redemtion
     */
    function initiate(
        address _redeemer,
        uint256 _expiry,
        uint256 _amount,
        bytes32 _secretHash
    ) external checkSafe(_redeemer, msg.sender, _expiry, _amount) {
        bytes32 OrderId = sha256(abi.encode(_secretHash, msg.sender));
        Order memory order = atomicSwapOrders[OrderId];
        require(order.redeemer == address(0x0), "AtomicSwap: duplicate order");
        Order memory newOrder = Order({
            redeemer: _redeemer,
            initiator: msg.sender,
            expiry: _expiry,
            initiatedAt: block.number,
            amount: _amount,
            isFulfilled: false
        });
        atomicSwapOrders[OrderId] = newOrder;
        emit Initiated(
            OrderId,
            _secretHash,
            newOrder.initiatedAt,
            newOrder.amount
        );
        token.safeTransferFrom(msg.sender, address(this), newOrder.amount);
    }

    /**
     * @notice  Signers with correct secret to an order's secret hash can redeem to claim the locked
     *          token
     * @dev     Signers are not allowed to redeem an order with wrong secret or redeem the same order
     *          multiple times
     * @param   _orderId  orderIds if the htlc order
     * @param   _secret  secret used to redeem an order
     */
    function redeem(bytes32 _orderId, bytes calldata _secret) external {
        Order storage order = atomicSwapOrders[_orderId];
        require(
            order.redeemer != address(0x0),
            "AtomicSwap: order not initated"
        );
        require(!order.isFulfilled, "AtomicSwap: order already fulfilled");
        bytes32 secretHash = sha256(_secret);
        require(
            sha256(abi.encode(secretHash, order.initiator)) == _orderId,
            "AtomicSwap: invalid secret"
        );
        order.isFulfilled = true;
        emit Redeemed(_orderId, secretHash, _secret);
        token.safeTransfer(order.redeemer, order.amount);
    }

    /**
     * @notice  Signers can refund the locked assets after expiry block number
     * @dev     Signers cannot refund the an order before epiry block number or refund the same order
     *          multiple times
     * @param   _orderId  orderId of the htlc order
     */
    function refund(bytes32 _orderId) external {
        Order storage order = atomicSwapOrders[_orderId];
        require(
            order.redeemer != address(0x0),
            "AtomicSwap: order not initated"
        );
        require(!order.isFulfilled, "AtomicSwap: order already fulfilled");
        require(
            order.initiatedAt + order.expiry < block.number,
            "AtomicSwap: order not expired"
        );
        order.isFulfilled = true;
        emit Refunded(_orderId);
        token.safeTransfer(order.initiator, order.amount);
    }
}

File 2 of 5 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 3 of 5 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}

File 4 of 5 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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'
        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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 5 of 5 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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://consensys.net/diligence/blog/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.8.0/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");

        (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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"secretHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"initiatedAt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Initiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderId","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"secrectHash","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"secret","type":"bytes"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderId","type":"bytes32"}],"name":"Refunded","type":"event"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"atomicSwapOrders","outputs":[{"internalType":"address","name":"redeemer","type":"address"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"initiatedAt","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"isFulfilled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_redeemer","type":"address"},{"internalType":"uint256","name":"_expiry","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes32","name":"_secretHash","type":"bytes32"}],"name":"initiate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_orderId","type":"bytes32"},{"internalType":"bytes","name":"_secret","type":"bytes"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_orderId","type":"bytes32"}],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b50604051610f3c380380610f3c83398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610e9c6100a06000396000818161012e015281816102ab015281816106a801526108f00152610e9c6000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80633f7b9c381461005c5780637249fbb6146100ee57806397ffc7ae14610103578063f7ff720714610116578063fc0c546a14610129575b600080fd5b6100af61006a366004610c2c565b6000602081905290815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909160ff1686565b604080516001600160a01b0397881681529690951660208701529385019290925260608401526080830152151560a082015260c0015b60405180910390f35b6101016100fc366004610c2c565b610168565b005b610101610111366004610c45565b6102d9565b610101610124366004610c8c565b6106df565b6101507f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100e5565b600081815260208190526040902080546001600160a01b03166101d25760405162461bcd60e51b815260206004820152601e60248201527f41746f6d6963537761703a206f72646572206e6f7420696e697461746564000060448201526064015b60405180910390fd5b600581015460ff16156101f75760405162461bcd60e51b81526004016101c990610d08565b438160020154826003015461020c9190610d4b565b106102595760405162461bcd60e51b815260206004820152601d60248201527f41746f6d6963537761703a206f72646572206e6f74206578706972656400000060448201526064016101c9565b60058101805460ff1916600117905560405182907ffe509803c09416b28ff3d8f690c8b0c61462a892c46d5430c8fb20abe472daf090600090a2600181015460048201546102d5916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692911690610921565b5050565b833384846001600160a01b03841661033f5760405162461bcd60e51b8152602060048201526024808201527f41746f6d6963537761703a20696e76616c69642072656465656d6572206164646044820152637265737360e01b60648201526084016101c9565b836001600160a01b0316836001600160a01b0316036103be5760405162461bcd60e51b815260206004820152603560248201527f41746f6d6963537761703a2072656465656d657220616e6420696e69746961746044820152746f722063616e6e6f74206265207468652073616d6560581b60648201526084016101c9565b600082116104255760405162461bcd60e51b815260206004820152602e60248201527f41746f6d6963537761703a206578706972792073686f756c642062652067726560448201526d61746572207468616e207a65726f60901b60648201526084016101c9565b6000811161047f5760405162461bcd60e51b815260206004820152602160248201527f41746f6d6963537761703a20616d6f756e742063616e6e6f74206265207a65726044820152606f60f81b60648201526084016101c9565b6000600286336040516020016104a89291909182526001600160a01b0316602082015260400190565b60408051601f19818403018152908290526104c291610d96565b602060405180830381855afa1580156104df573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906105029190610db2565b60008181526020818152604091829020825160c08101845281546001600160a01b0390811680835260018401549091169382019390935260028201549381019390935260038101546060840152600481015460808401526005015460ff16151560a083015291925090156105b85760405162461bcd60e51b815260206004820152601b60248201527f41746f6d6963537761703a206475706c6963617465206f72646572000000000060448201526064016101c9565b6040805160c0810182526001600160a01b038c811682523360208084019182528385018e81524360608601908152608086018f8152600060a088018181528b825281865290899020885181546001600160a01b0319908116918a16919091178255965160018201805490981698169790971790955591516002860155516003850181905590516004850181905592516005909401805460ff19169415159490941790935584519283528201529091899185917f3dd1f59c2a4b236fc1e76892b9a4b62de617c6a44a56ed208a3ba79c589823ab910160405180910390a360808101516106d2906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169033903090610989565b5050505050505050505050565b600083815260208190526040902080546001600160a01b03166107445760405162461bcd60e51b815260206004820152601e60248201527f41746f6d6963537761703a206f72646572206e6f7420696e697461746564000060448201526064016101c9565b600581015460ff16156107695760405162461bcd60e51b81526004016101c990610d08565b60006002848460405161077d929190610dcb565b602060405180830381855afa15801561079a573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107bd9190610db2565b600183015460408051602081018490526001600160a01b0390921690820152909150859060029060600160408051601f198184030181529082905261080191610d96565b602060405180830381855afa15801561081e573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108419190610db2565b1461088e5760405162461bcd60e51b815260206004820152601a60248201527f41746f6d6963537761703a20696e76616c69642073656372657400000000000060448201526064016101c9565b60058201805460ff19166001179055604051819086907f4c9a044220477b4e94dbb0d07ff6ff4ac30d443bef59098c4541b006954778e2906108d39088908890610ddb565b60405180910390a38154600483015461091a916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811692911690610921565b5050505050565b6040516001600160a01b03831660248201526044810182905261098490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526109c7565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526109c19085906323b872dd60e01b9060840161094d565b50505050565b6000610a1c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610a9c9092919063ffffffff16565b9050805160001480610a3d575080806020019051810190610a3d9190610e0a565b6109845760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101c9565b6060610aab8484600085610ab3565b949350505050565b606082471015610b145760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101c9565b600080866001600160a01b03168587604051610b309190610d96565b60006040518083038185875af1925050503d8060008114610b6d576040519150601f19603f3d011682016040523d82523d6000602084013e610b72565b606091505b5091509150610b8387838387610b8e565b979650505050505050565b60608315610bfd578251600003610bf6576001600160a01b0385163b610bf65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101c9565b5081610aab565b610aab8383815115610c125781518083602001fd5b8060405162461bcd60e51b81526004016101c99190610e33565b600060208284031215610c3e57600080fd5b5035919050565b60008060008060808587031215610c5b57600080fd5b84356001600160a01b0381168114610c7257600080fd5b966020860135965060408601359560600135945092505050565b600080600060408486031215610ca157600080fd5b83359250602084013567ffffffffffffffff80821115610cc057600080fd5b818601915086601f830112610cd457600080fd5b813581811115610ce357600080fd5b876020828501011115610cf557600080fd5b6020830194508093505050509250925092565b60208082526023908201527f41746f6d6963537761703a206f7264657220616c72656164792066756c66696c6040820152621b195960ea1b606082015260800190565b80820180821115610d6c57634e487b7160e01b600052601160045260246000fd5b92915050565b60005b83811015610d8d578181015183820152602001610d75565b50506000910152565b60008251610da8818460208701610d72565b9190910192915050565b600060208284031215610dc457600080fd5b5051919050565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215610e1c57600080fd5b81518015158114610e2c57600080fd5b9392505050565b6020815260008251806020840152610e52816040850160208701610d72565b601f01601f1916919091016040019291505056fea264697066735822122083a334bcafdce1a49fe2cff587175a99496fe0ce5cdcb963bad8cf57e85424bc64736f6c634300081200330000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100575760003560e01c80633f7b9c381461005c5780637249fbb6146100ee57806397ffc7ae14610103578063f7ff720714610116578063fc0c546a14610129575b600080fd5b6100af61006a366004610c2c565b6000602081905290815260409020805460018201546002830154600384015460048501546005909501546001600160a01b039485169593909416939192909160ff1686565b604080516001600160a01b0397881681529690951660208701529385019290925260608401526080830152151560a082015260c0015b60405180910390f35b6101016100fc366004610c2c565b610168565b005b610101610111366004610c45565b6102d9565b610101610124366004610c8c565b6106df565b6101507f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c59981565b6040516001600160a01b0390911681526020016100e5565b600081815260208190526040902080546001600160a01b03166101d25760405162461bcd60e51b815260206004820152601e60248201527f41746f6d6963537761703a206f72646572206e6f7420696e697461746564000060448201526064015b60405180910390fd5b600581015460ff16156101f75760405162461bcd60e51b81526004016101c990610d08565b438160020154826003015461020c9190610d4b565b106102595760405162461bcd60e51b815260206004820152601d60248201527f41746f6d6963537761703a206f72646572206e6f74206578706972656400000060448201526064016101c9565b60058101805460ff1916600117905560405182907ffe509803c09416b28ff3d8f690c8b0c61462a892c46d5430c8fb20abe472daf090600090a2600181015460048201546102d5916001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599811692911690610921565b5050565b833384846001600160a01b03841661033f5760405162461bcd60e51b8152602060048201526024808201527f41746f6d6963537761703a20696e76616c69642072656465656d6572206164646044820152637265737360e01b60648201526084016101c9565b836001600160a01b0316836001600160a01b0316036103be5760405162461bcd60e51b815260206004820152603560248201527f41746f6d6963537761703a2072656465656d657220616e6420696e69746961746044820152746f722063616e6e6f74206265207468652073616d6560581b60648201526084016101c9565b600082116104255760405162461bcd60e51b815260206004820152602e60248201527f41746f6d6963537761703a206578706972792073686f756c642062652067726560448201526d61746572207468616e207a65726f60901b60648201526084016101c9565b6000811161047f5760405162461bcd60e51b815260206004820152602160248201527f41746f6d6963537761703a20616d6f756e742063616e6e6f74206265207a65726044820152606f60f81b60648201526084016101c9565b6000600286336040516020016104a89291909182526001600160a01b0316602082015260400190565b60408051601f19818403018152908290526104c291610d96565b602060405180830381855afa1580156104df573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906105029190610db2565b60008181526020818152604091829020825160c08101845281546001600160a01b0390811680835260018401549091169382019390935260028201549381019390935260038101546060840152600481015460808401526005015460ff16151560a083015291925090156105b85760405162461bcd60e51b815260206004820152601b60248201527f41746f6d6963537761703a206475706c6963617465206f72646572000000000060448201526064016101c9565b6040805160c0810182526001600160a01b038c811682523360208084019182528385018e81524360608601908152608086018f8152600060a088018181528b825281865290899020885181546001600160a01b0319908116918a16919091178255965160018201805490981698169790971790955591516002860155516003850181905590516004850181905592516005909401805460ff19169415159490941790935584519283528201529091899185917f3dd1f59c2a4b236fc1e76892b9a4b62de617c6a44a56ed208a3ba79c589823ab910160405180910390a360808101516106d2906001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599169033903090610989565b5050505050505050505050565b600083815260208190526040902080546001600160a01b03166107445760405162461bcd60e51b815260206004820152601e60248201527f41746f6d6963537761703a206f72646572206e6f7420696e697461746564000060448201526064016101c9565b600581015460ff16156107695760405162461bcd60e51b81526004016101c990610d08565b60006002848460405161077d929190610dcb565b602060405180830381855afa15801561079a573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107bd9190610db2565b600183015460408051602081018490526001600160a01b0390921690820152909150859060029060600160408051601f198184030181529082905261080191610d96565b602060405180830381855afa15801561081e573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108419190610db2565b1461088e5760405162461bcd60e51b815260206004820152601a60248201527f41746f6d6963537761703a20696e76616c69642073656372657400000000000060448201526064016101c9565b60058201805460ff19166001179055604051819086907f4c9a044220477b4e94dbb0d07ff6ff4ac30d443bef59098c4541b006954778e2906108d39088908890610ddb565b60405180910390a38154600483015461091a916001600160a01b037f0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599811692911690610921565b5050505050565b6040516001600160a01b03831660248201526044810182905261098490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526109c7565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526109c19085906323b872dd60e01b9060840161094d565b50505050565b6000610a1c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610a9c9092919063ffffffff16565b9050805160001480610a3d575080806020019051810190610a3d9190610e0a565b6109845760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101c9565b6060610aab8484600085610ab3565b949350505050565b606082471015610b145760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101c9565b600080866001600160a01b03168587604051610b309190610d96565b60006040518083038185875af1925050503d8060008114610b6d576040519150601f19603f3d011682016040523d82523d6000602084013e610b72565b606091505b5091509150610b8387838387610b8e565b979650505050505050565b60608315610bfd578251600003610bf6576001600160a01b0385163b610bf65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101c9565b5081610aab565b610aab8383815115610c125781518083602001fd5b8060405162461bcd60e51b81526004016101c99190610e33565b600060208284031215610c3e57600080fd5b5035919050565b60008060008060808587031215610c5b57600080fd5b84356001600160a01b0381168114610c7257600080fd5b966020860135965060408601359560600135945092505050565b600080600060408486031215610ca157600080fd5b83359250602084013567ffffffffffffffff80821115610cc057600080fd5b818601915086601f830112610cd457600080fd5b813581811115610ce357600080fd5b876020828501011115610cf557600080fd5b6020830194508093505050509250925092565b60208082526023908201527f41746f6d6963537761703a206f7264657220616c72656164792066756c66696c6040820152621b195960ea1b606082015260800190565b80820180821115610d6c57634e487b7160e01b600052601160045260246000fd5b92915050565b60005b83811015610d8d578181015183820152602001610d75565b50506000910152565b60008251610da8818460208701610d72565b9190910192915050565b600060208284031215610dc457600080fd5b5051919050565b8183823760009101908152919050565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b600060208284031215610e1c57600080fd5b81518015158114610e2c57600080fd5b9392505050565b6020815260008251806020840152610e52816040850160208701610d72565b601f01601f1916919091016040019291505056fea264697066735822122083a334bcafdce1a49fe2cff587175a99496fe0ce5cdcb963bad8cf57e85424bc64736f6c63430008120033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599

-----Decoded View---------------
Arg [0] : _token (address): 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.