creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "london",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "contracts/BiblicalTruthDonations.sol": {
        "content": "// SPDX-License-Identifier: MIT\r\n\r\n// Website: www.biblicaltruth.io\r\n// Twitter / X: https://twitter.com/Bible316Truth\r\n// Telegram: https://t.me/biblicaltruthtoken\r\n// Discord: https://discord.gg/xqAkUBMf\r\n\r\n// Built with Love by: Decentral Bro's: https://www.decentralbros.xyz/\r\n\r\n//███████████████████████████████████████████████████████████████████\r\n//█░░░░░░░░░░░░░░███░░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░███░░░░░░██░░░░░░█\r\n//█░░▄▀▄▀▄▀▄▀▄▀░░███░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀▄▀░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░░░░░▄▀░░███░░░░░░▄▀░░░░░░█░░▄▀░░░░░░░░▄▀░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░██░░▄▀░░███████░░▄▀░░█████░░▄▀░░████░░▄▀░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░░░░░▄▀░░░░█████░░▄▀░░█████░░▄▀░░░░░░░░▄▀░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀▄▀▄▀▄▀▄▀▄▀░░█████░░▄▀░░█████░░▄▀▄▀▄▀▄▀▄▀▄▀░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░░░░░░░▄▀░░█████░░▄▀░░█████░░▄▀░░░░░░▄▀░░░░███░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░████░░▄▀░░█████░░▄▀░░█████░░▄▀░░██░░▄▀░░█████░░▄▀░░██░░▄▀░░█\r\n//█░░▄▀░░░░░░░░▄▀░░█████░░▄▀░░█████░░▄▀░░██░░▄▀░░░░░░█░░▄▀░░░░░░▄▀░░█\r\n//█░░▄▀▄▀▄▀▄▀▄▀▄▀░░█████░░▄▀░░█████░░▄▀░░██░░▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█\r\n//█░░░░░░░░░░░░░░░░█████░░░░░░█████░░░░░░██░░░░░░░░░░█░░░░░░░░░░░░░░█\r\n//███████████████████████████████████████████████████████████████████\r\n\r\n//────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\r\n//─████████████───██████████████─██████──────────██████─██████████████─██████████████─██████████─██████████████─██████──────────██████─██████████████─\r\n//─██░░░░░░░░████─██░░░░░░░░░░██─██░░██████████──██░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░██─██░░░░░░░░░░██─██░░██████████──██░░██─██░░░░░░░░░░██─\r\n//─██░░████░░░░██─██░░██████░░██─██░░░░░░░░░░██──██░░██─██░░██████░░██─██████░░██████─████░░████─██░░██████░░██─██░░░░░░░░░░██──██░░██─██░░██████████─\r\n//─██░░██──██░░██─██░░██──██░░██─██░░██████░░██──██░░██─██░░██──██░░██─────██░░██───────██░░██───██░░██──██░░██─██░░██████░░██──██░░██─██░░██─────────\r\n//─██░░██──██░░██─██░░██──██░░██─██░░██──██░░██──██░░██─██░░██████░░██─────██░░██───────██░░██───██░░██──██░░██─██░░██──██░░██──██░░██─██░░██████████─\r\n//─██░░██──██░░██─██░░██──██░░██─██░░██──██░░██──██░░██─██░░░░░░░░░░██─────██░░██───────██░░██───██░░██──██░░██─██░░██──██░░██──██░░██─██░░░░░░░░░░██─\r\n//─██░░██──██░░██─██░░██──██░░██─██░░██──██░░██──██░░██─██░░██████░░██─────██░░██───────██░░██───██░░██──██░░██─██░░██──██░░██──██░░██─██████████░░██─\r\n//─██░░██──██░░██─██░░██──██░░██─██░░██──██░░██████░░██─██░░██──██░░██─────██░░██───────██░░██───██░░██──██░░██─██░░██──██░░██████░░██─────────██░░██─\r\n//─██░░████░░░░██─██░░██████░░██─██░░██──██░░░░░░░░░░██─██░░██──██░░██─────██░░██─────████░░████─██░░██████░░██─██░░██──██░░░░░░░░░░██─██████████░░██─\r\n//─██░░░░░░░░████─██░░░░░░░░░░██─██░░██──██████████░░██─██░░██──██░░██─────██░░██─────██░░░░░░██─██░░░░░░░░░░██─██░░██──██████████░░██─██░░░░░░░░░░██─\r\n//─████████████───██████████████─██████──────────██████─██████──██████─────██████─────██████████─██████████████─██████──────────██████─██████████████─\r\n//────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\r\n\r\n// John 3:16\r\n// “For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, \r\n//  but have everlasting life.”\r\n\r\n//Imports:\r\n//IERC20.sol: This is the OpenZeppelin interface for ERC20 tokens, used to interact with ERC20-compliant token contracts.\r\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\r\n\r\npragma solidity ^0.8.17;\r\n\r\n//Contract Variables:\r\n//owner: Address of the contract owner.\r\n//totalRaised: Total amount of Ether raised across all campaigns.\r\n//goal: The fundraising goal amount for each campaign.\r\n//campaignCount: Number of campaigns created.\r\n//BiblicalTruthToken: Instance of the ERC20 token contract.\r\n//campaignRaised: Mapping to track the amount of Ether raised for each campaign.\r\n//campaignDetails: Mapping to store details (name, description, image hash) of each campaign.\r\ncontract BiblicalTruthDonations {\r\n    address public owner;\r\n    uint256 public totalRaised;\r\n    uint256 public goal;\r\n    uint256 public campaignCount;\r\n    IERC20 public BiblicalTruthToken;\r\n    mapping(uint256 => uint256) public campaignRaised;\r\n    mapping(uint256 => CampaignDetails) public campaignDetails;\r\n\r\n    //Events:\r\n    //DonationReceived: Triggered when a donation is received.\r\n    //Withdrawal: Triggered when Ether is withdrawn from the contract.\r\n    //CampaignReset: Triggered when a new campaign is started or an existing one is reset.\r\n    //FundsWithdrawnForCampaign: Triggered when funds are withdrawn for a specific campaign.\r\n    event DonationReceived(address donor, uint256 amount, uint256 campaignIndex);\r\n    event Withdrawal(address owner, uint256 amount);\r\n    event CampaignReset(uint256 campaignIndex, uint256 newGoal, string name, string description, string ipfsImageHash);\r\n    event FundsWithdrawnForCampaign(uint256 campaignIndex, uint256 amountWithdrawn);\r\n\r\n    //Struct:\r\n    //CampaignDetails: Struct to store campaign-related information like name, description, and image hash.\r\n    struct CampaignDetails {\r\n        string name;\r\n        string description;\r\n        string ipfsImageHash;\r\n    }\r\n\r\n    //Constructor:\r\n    // Initializes the contract with the owner address and sets the ERC20 token contract.\r\n    constructor(address _BiblicalTruthTokenAddress) {\r\n        owner = msg.sender;\r\n        BiblicalTruthToken = IERC20(_BiblicalTruthTokenAddress);\r\n        campaignCount = 0;\r\n    }\r\n\r\n    //Modifier:\r\n    //onlyOwner: Restricts access to functions only to the contract owner.\r\n    modifier onlyOwner() {\r\n        require(msg.sender == owner, \"Not the owner\");\r\n        _;\r\n    }\r\n    \r\n    function donate() public payable {\r\n        require(msg.value > 0, \"Donation must be greater than 0\");\r\n        campaignRaised[campaignCount] += msg.value;\r\n        if (campaignRaised[campaignCount] > goal) {\r\n            // Allow donations to exceed goal, excess will roll over to next campaign\r\n        }\r\n        totalRaised += msg.value;\r\n        emit DonationReceived(msg.sender, msg.value, campaignCount);\r\n    }\r\n\r\n\r\n    //Functions:\r\n    //donate: Allows users to donate Ether to the current campaign.\r\n    //withdraw: Allows the owner to withdraw Ether from the contract.\r\n    //resetCampaign: Allows the owner to reset the current campaign or start a new one with specified details.\r\n    //getBalance: Returns the Ether balance of the contract.\r\n    //getCampaignRaised: Returns the amount of Ether raised for a specific campaign.\r\n    //withdrawTokens: Allows the owner to withdraw ERC20 tokens from the contract.\r\n    function withdraw() public onlyOwner {\r\n        uint256 raised = campaignRaised[campaignCount];\r\n        uint256 amountToWithdraw = raised > goal ? goal : raised;\r\n        require(address(this).balance >= amountToWithdraw, \"Insufficient funds\");\r\n        (bool success, ) = owner.call{value: amountToWithdraw}(\"\");\r\n        require(success, \"Failed to send Ether\");\r\n\r\n        uint256 excess = raised - amountToWithdraw;\r\n        campaignRaised[campaignCount] = excess;\r\n\r\n        emit Withdrawal(owner, amountToWithdraw);\r\n    }\r\n\r\n\r\n    function resetCampaign(uint256 _newGoal, string memory _name, string memory _description, string memory _ipfsImageHash) public onlyOwner {\r\n        require(address(this).balance >= 0, \"No funds to start a new campaign\");\r\n        goal = _newGoal;\r\n        campaignCount += 1;\r\n        campaignRaised[campaignCount] = address(this).balance;\r\n\r\n        // Set the new campaign details\r\n        campaignDetails[campaignCount] = CampaignDetails({\r\n            name: _name,\r\n            description: _description,\r\n            ipfsImageHash: _ipfsImageHash\r\n        });\r\n\r\n        emit CampaignReset(campaignCount, _newGoal, _name, _description, _ipfsImageHash);\r\n    }\r\n\r\n\r\n    function getBalance() public view returns (uint256) {\r\n        return address(this).balance;\r\n    }\r\n\r\n    function getCampaignRaised(uint256 campaignIndex) public view returns (uint256) {\r\n        return campaignRaised[campaignIndex];\r\n    }\r\n\r\n    function withdrawTokens() public onlyOwner {\r\n        require(BiblicalTruthToken.balanceOf(address(this)) > 0, \"No tokens to withdraw\");\r\n        uint256 balance = BiblicalTruthToken.balanceOf(address(this));\r\n        BiblicalTruthToken.transfer(owner, balance);\r\n        emit Withdrawal(owner, balance);\r\n    }\r\n\r\n    //Fallback and Receive Functions:\r\n    //receive: Fallback function to accept Ether sent directly to the contract.\r\n    //fallback: Fallback function to accept Ether sent without data.\r\n    receive() external payable {}\r\n    fallback() external payable {}\r\n}"
      }
    }
  }}