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.8.4; | |
contract AbiExample { | |
string public myString = "hello world!"; | |
} |
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.8.4; | |
contract EventExample { | |
mapping(address => uint) public tokenBalance; | |
event TokensSent(address _from, address _to, uint _amount); | |
constructor() { | |
tokenBalance[msg.sender] = 100; | |
} |
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.8.4; | |
contract Owned { | |
address owner; | |
constructor() { | |
owner = msg.sender; | |
} | |
modifier onlyOwner { |
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.8.4; | |
import "./Owned.sol"; | |
contract InheritanceModifier is Owned { | |
mapping(address => uint) public tokenBalance; | |
uint tokenPrice = 1 ether; | |
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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.3; | |
contract FunctionsExample { | |
mapping(address => uint) public balanceReceived; | |
address payable owner; | |
constructor() { |
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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.8.4; | |
contract AlwaysFails { | |
function aFunction() public { | |
require(false, "Error message"); | |
} | |
} |
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
//SPDX-License-Identifier: MIT | |
pragma solidity 0.6.12; | |
contract Exceptions { | |
mapping(address => uint64) public balanceReceived; | |
function receiveMoney() public payable { | |
assert(msg.value == uint64(msg.value)); | |
balanceReceived[msg.sender] += uint64(msg.value); |
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
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.4; | |
contract MappingsStructExample { | |
struct Payment { | |
uint amount; | |
uint timestamp; | |
} | |
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.8.4; | |
contract SimpleMappingExample { | |
mapping(uint => bool) public myMapping; | |
mapping(address => bool) public myAddressMapping; | |
mapping (uint => mapping(uint => bool)) uintUintBoolMapping; | |
function setValue(uint _index) public { | |
myMapping[_index] = true; | |
} |
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.8.4; | |
contract StartingStopping { | |
address public owner; | |
bool public paused; | |
constructor() { | |
owner = msg.sender; | |
} | |
NewerOlder