Skip to content
Verified contractExactMIT

DeveloperDonations

Address0x620203af8ba83a712fbf78e65d10b13d72bdaee3
Balance

1.121 ETH

 

Transactions

5

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,306,081
Creation transaction
0xf6c34940e6…fdcbd0a274

src/DeveloperDonations.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";

/// @notice Minimal ETH donation box for The Developer crowdfund, evaluated as an alternative to a
/// Juicebox project (which charges a 2.5% protocol fee on withdrawals).
///
/// Model: donations only. No tokens, no refunds, no fee. Donations are accepted until `closesAt`
/// (inclusive); the owner can withdraw at any time, before or after the close. Ownership transfer
/// is two-step so a Safe or hardware wallet must prove it can act before it becomes the owner, and
/// ownership cannot be renounced (that would lock the balance for ever).
contract DeveloperDonations is Ownable2Step {
    /// @notice Unix time after which donations revert. Withdrawals are unaffected.
    uint64 public immutable closesAt;

    /// @notice Sum of every donation ever received, in wei. Never decreases; withdrawals do not touch it.
    uint256 public totalRaised;

    /// @notice Number of donations received.
    uint256 public donationCount;

    /// @notice Emitted once per donation. `memo` is free text chosen by the donor.
    event Donation(address indexed donor, uint256 amount, string memo);

    /// @notice Emitted when the owner moves funds out.
    event Withdrawal(address indexed to, uint256 amount);

    error CampaignClosed(uint64 closesAt);
    error ZeroAmount();
    error TransferFailed();
    error CloseInThePast(uint64 closesAt);
    error RenounceDisabled();

    /// @param initialOwner Address that can withdraw. Receives nothing automatically.
    /// @param closesAt_ Unix time of the last accepted donation (e.g. 1798761599 = 2026-12-31T23:59:59Z).
    constructor(address initialOwner, uint64 closesAt_) Ownable(initialOwner) {
        // forge-lint: disable-next-line(block-timestamp)
        if (closesAt_ <= block.timestamp) revert CloseInThePast(closesAt_);
        closesAt = closesAt_;
    }

    /// @notice A plain ETH transfer counts as a donation with an empty memo.
    receive() external payable {
        _donate("");
    }

    /// @notice Donate ETH with a public, on-chain message.
    function donate(string calldata memo) external payable {
        _donate(memo);
    }

    /// @notice True while donations are accepted.
    function isOpen() external view returns (bool) {
        // forge-lint: disable-next-line(block-timestamp)
        return block.timestamp <= closesAt;
    }

    /// @notice Send `amount` wei to `to`. Owner only. Works before and after the close.
    function withdraw(address payable to, uint256 amount) external onlyOwner {
        _withdraw(to, amount);
    }

    /// @notice Send the whole balance to `to`. Owner only.
    function withdrawAll(address payable to) external onlyOwner {
        _withdraw(to, address(this).balance);
    }

    /// @dev Disabled: an ownerless contract could never pay out.
    function renounceOwnership() public view override onlyOwner {
        revert RenounceDisabled();
    }

    function _donate(string memory memo) private {
        // forge-lint: disable-next-line(block-timestamp)
        if (block.timestamp > closesAt) revert CampaignClosed(closesAt);
        if (msg.value == 0) revert ZeroAmount();
        totalRaised += msg.value;
        unchecked {
            ++donationCount;
        }
        emit Donation(msg.sender, msg.value, memo);
    }

    function _withdraw(address payable to, uint256 amount) private {
        if (amount == 0) revert ZeroAmount();
        (bool ok,) = to.call{value: amount}("");
        if (!ok) revert TransferFailed();
        emit Withdrawal(to, amount);
    }
}

lib/openzeppelin-contracts/access/Ownable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

lib/openzeppelin-contracts/access/Ownable2Step.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     *
     * Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

lib/openzeppelin-contracts/utils/Context.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@bananapus/core-v6/=lib/core-v6/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/",
    "@uniswap/permit2/=lib/permit2/",
    "core-v6/=lib/core-v6/src/",
    "ds-test/=lib/permit2/lib/forge-std/lib/ds-test/src/",
    "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "permit2/=lib/permit2/",
    "solmate/=lib/permit2/lib/solmate/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.