All units are in order
pragma solidity ^0.7.0;
import "./some/library.sol";
import "./some/other-library.sol";
pragma solidity ^0.6.0; | |
contract Mappings { | |
// Mappings are data structure like dictionary in C# or hash tables in C++ | |
// O(1) | |
// mapping(key => value) myMapping; | |
// One can make nested mappings as well | |
// Mappings are like databases for blockchain and they are very useful | |
mapping(uint => string) public names; |
pragma solidity ^0.6.0; | |
contract MyContract { | |
uint[] public numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
address public owner; | |
constructor() public { | |
owner = msg.sender; |
pragma solidity ^0.6.0; | |
contract HotelRoom { | |
enum Statuses { Vacant, Occupied } | |
Statuses currentStatus; | |
event Occupy(address _occupant, uint _amount); | |
address payable public owner; |
pragma solidity >= 0.5.0 < 0.6.0; | |
// @author Andrej | |
// @title Election | |
contract Election { | |
address payable public contractOwner; | |
struct Candidate { | |
string name; |
pragma solidity ^0.5.1; | |
/** | |
* @dev ERC-721 non-fungible token standard. | |
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md. | |
*/ | |
interface ERC721 | |
{ | |
/** |
pragma solidity 0.4.24; | |
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/ChainlinkClient.sol"; | |
import "https://github.com/smartcontractkit/chainlink/evm-contracts/src/v0.4/vendor/Ownable.sol"; | |
contract ATestnetConsumer is ChainlinkClient, Ownable { | |
uint256 constant private ORACLE_PAYMENT = 1 * LINK; | |
uint256 public currentPrice; | |
int256 public changeDay; |
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.6.10; | |
/* | |
EtherStore is a contract where you can deposit any amount and withdraw at most | |
1 Ether per week. This contract is vulnerable to re-entrancy attack. | |
Let's see why. | |
1. Deploy EtherStore | |
2. Deposit 1 Ether each from Account 1 (Alice) and Account 2 (Bob) into EtherStore |
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.0; | |
// Simple contract to swap two variables in Solidity | |
contract Swapper { | |
uint8 public x = 1; | |
uint8 public y = 2; | |
function swap() public { |
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
// x -----> | |
// _______________ | |
// y |____|____|_____ | |
// |____|____|_____ | |
// |____|____|_____ | |
// |____|____|_____ |