Ethical Investment Filter Contract
What it does:
A smart contract that enforces ethical investment rules by allowing funds to be allocated only to whitelisted projects that meet predefined social, environmental, or governance standards.
Why it matters:
Many investors want their money to reflect their values, but traditional systems lack transparency. This contract ensures capital is deployed only to ethically approved projects, with rules enforced entirely on-chain.
How it works:
-
Ethical criteria are defined by the contract owner or DAO.
-
Approved investment targets are whitelisted on-chain.
-
Funds can only be invested into whitelisted addresses.
-
Any non-compliant transaction is automatically blocked.
-
All approvals and investments are transparently auditable.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title EthicalInvestmentFilter
* @author Nam
* @notice Restricts investments to ethically approved projects only
*/
contract EthicalInvestmentFilter {
// -------------------- DATA STRUCTURES --------------------
struct Project {
bool approved; // Ethical approval status
string metadataURI; // ESG / ethical documentation reference
}
mapping(address => Project) public projects;
address[] public approvedProjects;
address public owner;
// -------------------- EVENTS --------------------
event ProjectApproved(address indexed project, string metadataURI);
event ProjectRevoked(address indexed project);
event InvestmentExecuted(
address indexed investor,
address indexed project,
uint256 amount
);
// -------------------- MODIFIERS --------------------
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
modifier onlyApprovedProject(address _project) {
require(projects[_project].approved, "Project not approved");
_;
}
// -------------------- CONSTRUCTOR --------------------
constructor() {
owner = msg.sender;
}
// -------------------- ETHICAL GOVERNANCE --------------------
/**
* @notice Approve a project based on ethical criteria
* @param _project Project address
* @param _metadataURI Off-chain ESG or ethical documentation
*/
function approveProject(address _project, string calldata _metadataURI)
external
onlyOwner
{
require(_project != address(0), "Invalid address");
projects[_project] = Project({
approved: true,
metadataURI: _metadataURI
});
approvedProjects.push(_project);
emit ProjectApproved(_project, _metadataURI);
}
/**
* @notice Revoke ethical approval
*/
function revokeProject(address _project)
external
onlyOwner
{
require(projects[_project].approved, "Not approved");
projects[_project].approved = false;
emit ProjectRevoked(_project);
}
// -------------------- INVESTMENT LOGIC --------------------
/**
* @notice Invest ETH into an ethically approved project
*/
function invest(address payable _project)
external
payable
onlyApprovedProject(_project)
{
require(msg.value > 0, "Zero investment");
_project.transfer(msg.value);
emit InvestmentExecuted(
msg.sender,
_project,
msg.value
);
}
// -------------------- VIEW FUNCTIONS --------------------
/**
* @notice Get approved project count
*/
function approvedProjectCount() external view returns (uint256) {
return approvedProjects.length;
}
/**
* @notice Get project info
*/
function getProject(address _project)
external
view
returns (
bool approved,
string memory metadataURI
)
{
Project memory p = projects[_project];
return (
p.approved,
p.metadataURI
);
}
}