sabato 12 marzo 2016
SOLIDITY - info getter
contract basicInfoGetter {
address creator;
function basicInfoGetter() public
{
creator = msg.sender;
}
function getMsgSender() constant returns (address) // Returns the address of whomever made this call
{ // (i.e. not necessarily the creator of the contract)
return msg.sender;
}
function getMsgValue() constant returns (uint) // returns amt of wei sent with this call
{
return msg.value;
}
function getContractAddress() constant returns (address)
{
return this;
}
function getContractBalance() constant returns (uint)
{
return this.balance;
}
/**********
Standard kill() function to recover funds
**********/
function kill()
{
if (msg.sender == creator)
suicide(creator); // kills this contract and sends remaining funds back to creator
}
}
/*
var abi = [{
"constant": true,
"inputs": [],
"name": "getContractAddress",
"outputs": [{
"name": "",
"type": "address"
}],
"type": "function"
}, {
"constant": false,
"inputs": [],
"name": "kill",
"outputs": [{
"name": "",
"type": "bool"
}],
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "getContractBalance",
"outputs": [{
"name": "",
"type": "uint256"
}],
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "getMsgSender",
"outputs": [{
"name": "",
"type": "address"
}],
"type": "function"
}, {
"constant": true,
"inputs": [],
"name": "getMsgValue",
"outputs": [{
"name": "",
"type": "uint256"
}],
"type": "function"
}, {
"inputs": [],
"type": "constructor"
}];
*/
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento