Commit f07f20ce authored by Quentin Bramas's avatar Quentin Bramas
Browse files

nothing

parent 4266a82f
pragma solidity >=0.4.26 <0.5.0;
contract WinnerString {
struct Person {
uint256 donation;
string favoriteString;
}
string public winnerString;
mapping(address => Person) public donators;
address public bestDonator;
uint256 public bestDonation;
function getBestDonator() public view return address {
return bestDonator;
}
function donate() public payable
{
Person storage donator = donators[msg.sender];
donator.donation += msg.value;
if(donator.donation > bestDonation)
{
bestDonator = msg.sender;
}
}
function changeWinnerString(string memory _str) public
{
require(msg.sender == bestDonator);
winnerString = _str;
donators[msg.sender].favoriteString = _str;
}
function withdraw() public {
require(msg.sender != bestDonator);
Person storage donator = donators[msg.sender];
donator.donation = 0;
msg.sender.transfer(
donators[msg.sender].donation
);
}
}
[{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winnerString","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bestDonator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_s","type":"string"}],"name":"changeWinnerString","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxDonation","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"donatedBy","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"donators","outputs":[{"name":"favoriteString","type":"string"},{"name":"donated","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"donate","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"}]
\ No newline at end of file
608060405260206040519081016040528060008152506000908051906020019061002a929190610042565b50600060025534801561003c57600080fd5b506100e7565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008357805160ff19168380011785556100b1565b828001600101855582156100b1579182015b828111156100b0578251825591602001919060010190610095565b5b5090506100be91906100c2565b5090565b6100e491905b808211156100e05760008160009055506001016100c8565b5090565b90565b610872806100f66000396000f30060806040526004361061008e576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633ccfd60b1461009d5780635be097e2146100b457806382958ec914610144578063a78ae3d41461019b578063a8681fd914610204578063ccf3aa551461022f578063d24f8cdd1461025a578063ed88c68e1461031d575b34801561009a57600080fd5b50005b3480156100a957600080fd5b506100b2610327565b005b3480156100c057600080fd5b506100c96104a8565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101095780820151818401526020810190506100ee565b50505050905090810190601f1680156101365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561015057600080fd5b50610159610546565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156101a757600080fd5b50610202600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061056c565b005b34801561021057600080fd5b506102196105e2565b6040518082815260200191505060405180910390f35b34801561023b57600080fd5b506102446105e8565b6040518082815260200191505060405180910390f35b34801561026657600080fd5b5061029b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610632565b6040518080602001838152602001828103825284818151815260200191508051906020019080838360005b838110156102e15780820151818401526020810190506102c6565b50505050905090810190601f16801561030e5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b6103256106ee565b005b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206001015411151561037857600080fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515156103d557600080fd5b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101819055503373ffffffffffffffffffffffffffffffffffffffff166108fc600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101549081150290604051600060405180830381858888f193505050501580156104a5573d6000803e3d6000fd5b50565b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561053e5780601f106105135761010080835404028352916020019161053e565b820191906000526020600020905b81548152906001019060200180831161052157829003601f168201915b505050505081565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105c857600080fd5b80600090805190602001906105de9291906107a1565b5050565b60025481565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010154905090565b6001602052806000526040600020600091509050806000018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156106de5780601f106106b3576101008083540402835291602001916106de565b820191906000526020600020905b8154815290600101906020018083116106c157829003601f168201915b5050505050908060010154905082565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090503481600101600082825401925050819055506002548160010154111561079e57806001015460028190555033600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106107e257805160ff1916838001178555610810565b82800160010185558215610810579182015b8281111561080f5782518255916020019190600101906107f4565b5b50905061081d9190610821565b5090565b61084391905b8082111561083f576000816000905550600101610827565b5090565b905600a165627a7a72305820bd837d474ba2a3d63ba4d4d7fe2c127a2c7c406396cddd3cbf75db4e1255c9d10029
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment