Skip to content
Verified contractPartialUNLICENSED

PaymentsV2

Address0x2e046c503f69dbeefedb78b65f882cfb5440f9a5
Balance

0.596894 ETH

 

Transactions

70

 

Compiler

solc 0.8.24

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.24+commit.e11b9ed9
Language
solidity
Optimization
Yes, 200 runs
EVM version
shanghai
License
UNLICENSED
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
19,540,459
Creation transaction
0xb590670388…bf92ee9e83

PaymentsV2.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

interface ChainlinkOracle {
    function latestAnswer() external view returns (int256);

    function decimals() external view returns (uint8);
}

contract PaymentsV2 {
    address public deployer;
    address public chainlinkETHFeed =
        0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
    bool public isDepositOpen;

    mapping(string => uint256) public dollarDepositAmount;

    event Deposit(
        string depositor,
        uint256 ethValue,
        uint256 dollarValue,
        uint256 timestamp
    );

    constructor() payable {
        deployer = msg.sender;
    }

    function setChainlinkETHFeed(address _chainlinkETHFeed) external {
        require(msg.sender == deployer, "No permission");
        chainlinkETHFeed = _chainlinkETHFeed;
    }

    function deposit(string calldata _depositor) external payable {
        require(isDepositOpen == true, "Deposit not open");

        uint ethPrice = uint(ChainlinkOracle(chainlinkETHFeed).latestAnswer());
        require(ethPrice > 0, "Invalid ETH price");

        uint8 chainlinkPriceFeedDecimals = ChainlinkOracle(chainlinkETHFeed)
            .decimals();

        uint depositAmountETH = msg.value;
        // Only 16 to keep Dollars in cents
        uint depositAmountDollar = (depositAmountETH * ethPrice) /
            (10 ** (16 + chainlinkPriceFeedDecimals));

        dollarDepositAmount[_depositor] += depositAmountDollar;

        emit Deposit(
            _depositor,
            depositAmountETH,
            depositAmountDollar,
            block.timestamp
        );
    }

    function getUserTotalDeposit(
        string calldata user
    ) external view returns (uint) {
        return dollarDepositAmount[user];
    }

    //////////////////////////////////////////////////////////Admin Functions////////////////////////////////////////////////

    function extractValue() external {
        require(msg.sender == deployer, "No permission");

        if (address(this).balance > 0) {
            payable(deployer).transfer(address(this).balance);
        }
    }

    function toggleDeposit(bool isOpen) external {
        require(msg.sender == deployer, "No permission");
        isDepositOpen = isOpen;
    }

    receive() external payable {}
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.