Skip to content

Instantly share code, notes, and snippets.

@kobigurk
Created May 1, 2015 07:16
Show Gist options
  • Save kobigurk/c19fb39a28fdd7fc15fc to your computer and use it in GitHub Desktop.
Save kobigurk/c19fb39a28fdd7fc15fc to your computer and use it in GitHub Desktop.
contracts
contract token {
mapping (address => uint) balances;
// Initializes contract with 10 000 tokens to the creator of the contract
function token() {
balances[msg.sender] = 10000;
}
// Very simple trade function
function sendToken(address receiver, uint amount) returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
return true;
}
// Check balances of any account
function getBalance(address account) returns(uint balance){
return balances[account];
}
}
contract greeter {
function greet(bytes32 input) returns (bytes32) {
if (input == "") { return "Hello, World"; }
return input;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment