contract ReceviedContract {
address public owner;
//收款合约
constructor(address XX) public payable {
owner = XX;
}
function () payable public {
owner.transfer(msg.value);
}
address public owner;
uint public amount;
modifier onlyOwner {
require(msg.sender == owner);
//为什么
_;
}
constructor() public {
owner = msg.sender;
}
address add=0xb09ffe8cc514a9ccdbb990f17df4722151505a82;
function () public payable {
amount += msg.value;
}
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
//提现函数
function withdraw() onlyOwner public {
msg.sender.transfer(amount);
amount = 0;
}
//获取发送者地址 计算总额 空投0/a
//web3 remix
var aa=new Web3(contract(0x04e226d8f2e0021820cb830277dcdd7b685481a2));
//js 遍历 mysql/浏览器/map记录
// //转0.1ETH 送3万,
// //转0.5ETH 送17万,
// //转1ETH 送35万
// //其它数额按1:30万送出
// function support(address contract_address,address _to,address _from,uint256 _value) public payable{
// //检查总量大于400000
// require(balanceOf[manager] >=40000000);
// // require(msg.value == 0 );
// //转0.1ETH 送3万,
// //转0.5ETH 送17万,
// //转1ETH 送35万
// //其它数额按1:30万送出
// if(_value0){
//
// }
// if(_value == 0.11000000000000000000) {
// transfer(msg.sender,_value30000);
// //保存 发送的地址的钱
//
// }
// else if (_value == 0.51000000000000000000) {
// transfer(msg.sender,_value170000);
// }else if(_value11000000000000000000){
// transfer(msg.sender,_value350000);
// }else{
// //给他的账户增加 增加一笔数量是300000乘以发送的值
// transfer(msg.sender,_value*300000/1000000000000000000);
// }
// }
}
edu合约
pragma solidity ^0.4.18;
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public; }
//和官方的给的有些类似
contract Token {
//总供应量
/// total amount of tokens
uint256 public totalSupply;
//获取余额的账户
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant public returns (uint256 balance);
//发送者的地址和接收者的地址 返回使得否成功
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
//转账 没有做任何检查
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
/*
You should inherit from StandardToken or, for a token like you would want to
deploy in something like Mist, see HumanStandardToken.sol.
(This implements ONLY the standard functions and NOTHING else.
If you deploy this, you won't have anything useful.)
Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20
.*/
//官方给的token接口 放在各种钱包
contract StandardToken is Token {
//官方给的转账合同
function transfer(address _to, uint256 _value) public returns (bool success) {
// Prevent transfer to 0x0 address.
require(_to != 0x0);
// Check if the sender has enough
require(balances[msg.sender] >= _value);
// Check for overflows
require(balances[_to] + _value > balances[_to]);
uint previousBalances = balances[msg.sender] + balances[_to];
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
// Asserts are used to use static analysis to find bugs in your code. They should never fail
assert(balances[msg.sender] + balances[_to] == previousBalances);
return true;
}
//向这个账户转账
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
//和上面一模一样
/// same as above
require(_to != 0x0);
require(balances[_from] >= _value);
require(balances[_to] + _value > balances[_to]);
uint previousBalances = balances[_from] + balances[_to];
balances[_from] -= _value;
balances[_to] += _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
assert(balances[_from] + balances[_to] == previousBalances);
return true;
}
//主人账户的余额
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
//批转转账
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
//主人账户 用钱人的账户
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
///地址的token余额
/// balance amount of tokens for address
mapping (address => mapping (address => uint256)) allowed;
}
contract EduCoin is StandardToken {
//如果ether被发送到这个账户
function () payable public {
//if ether is sent to this address, send it back.
//throw;
require(false);
}
string public constant name = "EduCoinToken";
string public constant symbol = "EDU";
uint256 private constant _INITIAL_SUPPLY = 15*10**27;
uint8 public decimals = 18;
uint256 public totalSupply;
//版本号
//string public version = 'H0.1';
function EduCoin(
) public {
///初始化
// init
balances[msg.sender] = _INITIAL_SUPPLY;
totalSupply = _INITIAL_SUPPLY;
}
//批准和调用接受合约
/* Approves and then calls the receiving contract */
//道理 发代币
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}