-
-
Save ravachol70/40411d088aa7d0f2ffa06ec00c6c75c1 to your computer and use it in GitHub Desktop.
Contract Addresses: Coffee Contract Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Coffee | |
* | |
* Just a very simple example of deploying a contract at a vanity address | |
* across several chains. | |
* | |
* See: https://blog.ricmoo.com/contract-addresses-549074919ec8 | |
* | |
*/ | |
pragma solidity ^0.4.20; | |
contract Coffee { | |
address _owner; | |
uint48 _mgCaffeine; | |
uint48 _count; | |
function Coffee() { | |
_owner = msg.sender; | |
} | |
/** | |
* Allow the owner to change the account that controls this contract. | |
* | |
* We may wish to use powerful computers that may be public or | |
* semi-public to compute the private key we use to deploy the contract, | |
* to a vanity adddress. So once deployed, we want to move it to a | |
* cold-storage key. | |
*/ | |
function setOwner(address owner) { | |
require(msg.sender == _owner); | |
_owner = owner; | |
} | |
/** | |
* status() | |
* | |
* Returns the number of drinks and amount of caffeine this contract | |
* has been responsible for installing into the developer. | |
*/ | |
function status() public constant returns (uint48 count, uint48 mgCaffeine) { | |
count = _count; | |
mgCaffeine = _mgCaffeine; | |
} | |
/** | |
* withdraw(amount, count, mgCaffeine) | |
* | |
* Withdraws funds from this contract to the owner, indicating how many drinks | |
* and how much caffeine these funds will be used to install into the develoepr. | |
*/ | |
function withdraw(uint256 amount, uint8 count, uint16 mgCaffeine) public { | |
require(msg.sender == _owner); | |
_owner.transfer(amount); | |
_count += count; | |
_mgCaffeine += mgCaffeine; | |
} | |
// Let this contract accept payments | |
function () public payable { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0xf9035580847d2b75008307a1208080b903036060604052341561000f57600080fd5b60008054600160a060020a033316600160a060020a03199091161790556102c88061003b6000396000f3006060604052600436106100565763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313af40358114610058578063200d2ed214610084578063e228a6f4146100ba575b005b341561006357600080fd5b61005673ffffffffffffffffffffffffffffffffffffffff600435166100dd565b341561008f57600080fd5b610097610141565b60405165ffffffffffff9283168152911660208201526040908101905180910390f35b34156100c557600080fd5b61005660043560ff6024351661ffff60443516610189565b6000543373ffffffffffffffffffffffffffffffffffffffff90811691161461010557600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005465ffffffffffff7a0100000000000000000000000000000000000000000000000000008204811692740100000000000000000000000000000000000000009092041690565b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116146101b157600080fd5b60005473ffffffffffffffffffffffffffffffffffffffff1683156108fc0284604051600060405180830381858888f1935050505015156101f157600080fd5b6000805479ffffffffffff00000000000000000000000000000000000000001979ffffffffffffffffffffffffffffffffffffffffffffffffffff821660ff959095167a0100000000000000000000000000000000000000000000000000009283900465ffffffffffff9081169190910181169092029490941793841661ffff93909316740100000000000000000000000000000000000000009485900482160116909202179055505600a165627a7a7230582091c9642676bc460cc1a29f4ce4b0a5285fa5995cb7c21da58c6f26e1634b1ac300291ca008a6d0bc07d3c38c9ae38a1e2d369bf8b507bce55850bd5b27e2763a219a7f53a06c75668b362e494053f1198b9c157c103d6c625b78b3ed3e99674fc58eef1a0c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment