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
pragma solidity >=0.5.0; | |
contract AccessModifiers { | |
// Public modifer exposes a getter for state variable | |
string public myString; | |
// Private variable only accessible within contract | |
string private myPrivateString; | |
// Internal functions can only be used within this contract | |
function innerFunction() internal {} |
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
pragma solidity >=0.5.0; | |
contract RequireStatements { | |
function someFunction(address _anAddress) external { | |
// Require that the address given as a parameter is not equal to an empty addess. | |
// If the address is empty, the whole transaction will not be completed and will be reverted | |
require(_anAddress != address(0), "Not a valid address"); | |
... | |
} |
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
pragma solidity >=0.5.0; | |
contract CustomModifiers { | |
// State variable | |
address private owner; | |
// Custom modifier requiring that the sender of the transaction is the owner | |
// otherwise revert the transaction | |
modifier onlyOwner { |
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
pragma solidity >=0.5.0; | |
contract Mappings { | |
// State variable | |
mapping(address => uint) public myMapping; | |
// Store a new value in the mapping | |
function putThing(address _key, uint _value) public { | |
myMapping[_key] = _value; |
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
pragma solidity >=0.5.0; | |
contract Structs { | |
// Define the Person struct | |
struct Person { | |
string name; | |
uint8 age; | |
} |
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
pragma solidity >=0.5.0; | |
contract Vehicle { | |
} | |
contract Car is Vehicle { | |
} |
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
pragma solidity ^0.5.5; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
contract Ethermon is ERC721 { | |
} |
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
const Ethermon = artifacts.require("Ethermon"); | |
module.exports = function(deployer) { | |
deployer.deploy(Ethermon); | |
}; |
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
pragma solidity ^0.5.5; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
contract Ethermon is ERC721 { | |
struct Monster { | |
string name; | |
uint level; | |
} |
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
pragma solidity ^0.5.5; | |
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | |
contract Ethermon is ERC721 { | |
struct Monster { | |
string name; | |
uint level; | |
} |