Verified contractPartial
BlockchainForPeace
Address0x977116807902bd4d5d763da7aa43dbb4e408259b
- Balance
0 ETH
- Transactions
19
- Compiler
solc 0.4.24
- Same code
Only this contract
Details
- Compiler
- solc 0.4.24+commit.e67f0147
- Language
- solidity
- Optimization
- No
- License
- Not stated
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 6,306,773
- Creation transaction
- 0x6939efe079…ec901ee3ba
BlockchainForPeace.sol
pragma solidity ^0.4.24;
contract BlockchainForPeace {
// to see the total raised
uint public raised;
address public charity;
//struct for the donation
struct Donation {
address donor;
string message;
uint value;
}
Donation[] public donations;
//mapping an address to the donation struct
//mapping (address => donation) public donors;
event Donate(address indexed from, uint amount, string message);
//constructor to initiate the address of the charity being donated to
constructor () public {
charity = 0xaf208FF43D2A265E047D52C9F54c753DB86D9D11;
}
// payable function which auto transfers money to charity address, collects the value and increases the total value counter. Also allows for anonoymous donations
function fallback() payable public {
raised += msg.value;
charity.transfer(msg.value);
}
// optional message to be sent with donation, peace message.
function messageForPeace(string _message) payable public {
require(msg.value > 0);
donations.push(Donation(msg.sender, _message, msg.value));
charity.transfer(msg.value);
raised += msg.value;
emit Donate(msg.sender, msg.value, _message);
}
function getDonation(uint _index) public view returns (address, string, uint) {
Donation memory don = donations[_index];
return (don.donor, don.message, don.value);
}
function getDonationLength() public view returns (uint){
return donations.length;
}
function getRaised() public view returns (uint){
return raised;
}
}Compiler settingsShow
{
"optimizer": {
"runs": 0,
"enabled": false
}
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.