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.7; | |
contract Counter { | |
uint deployTime; | |
uint public count; | |
constructor() { | |
deployTime = block.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.7.0 <0.9.0; | |
contract MyContract { | |
uint[] public arr = [1,2,3,4,5,6,7,8,9,10]; | |
uint[] public res; | |
function startWork() public { | |
for (uint i = 0; i < arr.length; i++) { | |
if(arr[i] % 2 == 0) { | |
res.push(arr[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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.13; | |
interface IERC721 { | |
function safeTransferFrom( | |
address from, | |
address to, | |
uint tokenId | |
) external; |
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.13; | |
contract ByteCodeManager { | |
function getBytecode(address _owner, uint _foo) public pure returns (bytes memory) { | |
bytes memory bytecode = type(TestContract).creationCode; | |
return abi.encodePacked(bytecode, abi.encode(_owner, _foo)); | |
} |
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.0; | |
contract YouDeposit { | |
mapping(address => uint) balances; | |
function deposit() public payable { | |
require(msg.value > 0, "No value sent"); | |
balances[msg.sender] += 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.7; | |
// Deposit funds into a contract and keep track of the funds | |
contract HelloWorld { | |
mapping (address => uint) public bal; | |
fallback() external payable {} |
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.7; | |
// Deposit funds into a contract and keep track of the funds | |
contract HelloWorld { | |
mapping (address => uint) public bal; | |
fallback() external payable {} |
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: GPL-3.0 | |
pragma solidity 0.8.4; | |
contract Energy{ | |
//have total supply | |
//transferrable | |
//name | |
//symbol |
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.8; | |
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/Pausable.sol"; | |
interface IERC20 { | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
event Approval(address indexed owner, address indexed spender, uint256 value); | |
function totalSupply() external view returns (uint256); |
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
const { | |
time, | |
loadFixture, | |
} = require("@nomicfoundation/hardhat-network-helpers"); | |
const { anyValue } = require("@nomicfoundation/hardhat-chai-matchers/withArgs"); | |
const { expect } = require("chai"); | |
describe("Lock", function () { | |
// We define a fixture to reuse the same setup in every test. | |
// We use loadFixture to run this setup once, snapshot that state, |
OlderNewer