This file contains 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
contract Wallet is WalletEvents { | |
... | |
// METHODS | |
// gets called when no other function matches | |
function() payable { | |
// just being sent some cash? | |
if (msg.value > 0) | |
Deposit(msg.sender, msg.value); | |
else if (msg.data.length > 0) | |
_walletLibrary.delegatecall(msg.data); |
This file contains 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
contract HashForEther { | |
function withdrawWinnings() { | |
// Winner if the last 8 hex characters of the address are 0. | |
require(uint32(msg.sender) == 0); | |
_sendWinnings(); | |
} | |
function _sendWinnings() { | |
msg.sender.transfer(this.balance); |
This file contains 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
contract WalletLibrary is WalletEvents { | |
... | |
// METHODS | |
... | |
// constructor is given number of sigs required to do protected "onlymanyowners" transactions | |
// as well as the selection of addresses capable of confirming them. | |
function initMultiowned(address[] _owners, uint _required) { |
This file contains 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
//encryption contract | |
contract Rot13Encryption { | |
event Result(string convertedString); | |
//rot13 encrypt a string | |
function rot13Encrypt (string text) public { | |
uint256 length = bytes(text).length; | |
for (var i = 0; i < length; i++) { | |
byte char = bytes(text)[i]; |
This file contains 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
import "Rot13Encryption.sol"; | |
// encrypt your top secret info | |
contract EncryptionContract { | |
// library for encryption | |
Rot13Encryption encryptionLibrary; | |
// constructor - initialise the library | |
constructor(Rot13Encryption _encryptionLibrary) { | |
encryptionLibrary = _encryptionLibrary; | |
} |
This file contains 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
//encryption contract | |
contract Rot26Encryption { | |
event Result(string convertedString); | |
//rot13 encrypt a string | |
function rot13Encrypt (string text) public { | |
uint256 length = bytes(text).length; | |
for (var i = 0; i < length; i++) { | |
byte char = bytes(text)[i]; |
This file contains 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
contract Print{ | |
event Print(string text); | |
function rot13Encrypt(string text) public { | |
emit Print(text); | |
} | |
} |
This file contains 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
contract Blank { | |
event Print(string text); | |
function () { | |
emit Print("Here"); | |
//put malicious code here and it will run | |
} | |
} |
This file contains 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
pragma solidity ^0.4.19; | |
contract Private_Bank | |
{ | |
mapping (address => uint) public balances; | |
uint public MinDeposit = 1 ether; | |
Log TransferLog; | |
function Private_Bank(address _log) | |
{ | |
TransferLog = Log(_log); |
This file contains 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
contract Lotto { | |
bool public payedOut = false; | |
address public winner; | |
uint public winAmount; | |
// ... extra functionality here | |
function sendToWinner() public { | |
require(!payedOut); | |
winner.send(winAmount); | |
payedOut = true; |