{
address: "0x0da81b5da0e5b6a4615d3499d31bb34f0e35a74e",
balance: {
type: "BigNumber",
hex: "0x0de0b6b3a7640000"
string: "1000000000000000000"
ether: "1.0"
},
"transactions": [],
code: "
/*
Name: Faucet Contract
Version: 0.0.3
*/
class Faucet {
allocations = {}; // liste de Allocation : {totalAmount, lastAmount, lastTimestamp} indexée par address
minAmountPerDay = number('10' + '000000000000000000'); // 10
maxAmountPerDay = number('50' + '000000000000000000'); // 50
totalAllocated = number(0);
allocationsDelay = 86400;
Faucet(recipient, amount) {} // event
getFreeMoney(recipient) {
const tokenAllocations = this.allocations || {};
require(address(this).balance.gt(0), "INSUFFICIENT_FAUCET_BALANCE");
if (! recipient) {
_throw('MISSING_SENDER_ADDRESS');
}
if (recipient in tokenAllocations && tokenAllocations[recipient].lastTimestamp > Date.now() - this.allocationsDelay * 1000) {
_throw('TOO_SOON');
}
const diffMinMax = this.maxAmountPerDay.sub(this.minAmountPerDay);
const rnd = Math.round(Math.random() * 1000);
let amount = this.minAmountPerDay.add( diffMinMax.mul(rnd).div(1000) );
//const amount = number('2000000000000000000');
if (amount.lt(this.minAmountPerDay)) {
amount = this.minAmountPerDay;
}
if (amount.gt(address(this).balance)) {
amount = address(this).balance;
}
if (amount.gt(this.maxAmountPerDay)) {
amount = this.maxAmountPerDay;
}
if (! (recipient in tokenAllocations)) {
tokenAllocations[recipient] = {
totalAmount: number(0),
lastAmount: number(0),
lastTimestamp: number(0),
};
}
tokenAllocations[recipient].totalAmount = tokenAllocations[recipient].totalAmount.add(amount);
tokenAllocations[recipient].lastAmount = amount;
tokenAllocations[recipient].lastTimestamp = Date.now();
address(recipient).transfer(amount); // send free money to recipient
address(msg.sender).transfer( number(1e18.toString()) ); // send money for gas payment thanks
this.totalAllocated = this.totalAllocated.add(amount);
emit('Faucet', [recipient, amount]);
return [amount];
}
}
// Events
Faucet.prototype.Faucet.event = true;
Faucet.prototype.Faucet.inputs = ['address indexed', 'uint256'];
// Methods
Faucet.prototype.getFreeMoney.inputs = ['address'];
Faucet.prototype.getFreeMoney.outputs = ['uint256'];
return Faucet;
",
codeHash: "0x9232aff080256517c36d3d05edd979e7b672e79abb412712af4c65bdf7d84919",
codeAbi: {
0xc358234b: {
constant: true,
"inputs": [],
name: "allocations",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x88c53fe6: {
constant: true,
"inputs": [],
name: "minAmountPerDay",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x381fc009: {
constant: true,
"inputs": [],
name: "maxAmountPerDay",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x45f7f249: {
constant: true,
"inputs": [],
name: "totalAllocated",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x2bd99c18: {
constant: true,
"inputs": [],
name: "allocationsDelay",
outputs: [
{
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0xa8ac9b50: {
constant: true,
"inputs": [],
name: "prototype",
outputs: [
{
name: "",
type: "string"
}
],
payable: false,
stateMutability: "view",
type: "function"
},
0x1c5347d1: {
inputs: [
{
name: "recipient",
type: "address",
indexed: true
},
{
name: "amount",
type: "uint256",
indexed: false
}
],
name: "Faucet",
"outputs": [],
stateMutability: "nonpayable",
type: "event"
},
0x418083f9: {
inputs: [
{
name: "recipient",
type: "address"
}
],
name: "getFreeMoney",
outputs: [
{
name: "",
type: "uint256"
}
],
stateMutability: "nonpayable",
type: "function"
}
},
contractName: "Faucet",
storage: {
prototype: {
address: "0x0da81b5da0e5b6a4615d3499d31bb34f0e35a74e"
},
"allocations": {},
minAmountPerDay: {
type: "BigNumber",
hex: "0x8ac7230489e80000"
string: "10000000000000000000"
ether: "10.0"
},
maxAmountPerDay: {
type: "BigNumber",
hex: "0x02b5e3af16b1880000"
string: "50000000000000000000"
ether: "50.0"
},
totalAllocated: {
type: "BigNumber",
hex: "0x00"
string: "0"
ether: "0.0"
},
allocationsDelay: 86400
},
storageHash: "0xacc567f8900448b11de837128c2b473b7aa4b1ff8532ea3084fb9fc1d64e1fdb",
savedOnBlockNumber: {
type: "BigNumber",
hex: "0x27"
string: "39"
ether: "0.000000000000000039"
}
}