Skip to content

Instantly share code, notes, and snippets.

// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
async function main() {
// Hardhat always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
// to make sure everything is compiled
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("@nomiclabs/hardhat");
async function main() {
// Hardhat always runs the compile task when running scripts through it.
// If this runs in a standalone fashion you may want to call compile manually
// to make sure everything is compiled
pragma solidity >=0.4.21 <0.6.0;
contract TennisMatch {
address public owner;
uint8 public playerAScore = 0;
uint8 public playerAGamesWon = 0;
uint8 public playerBScore = 0;
uint8 public playerBGamesWon = 0;
pragma solidity >=0.4.21 <0.6.0;
contract TennisMatch {
address public owner;
uint8 public playerAScore = 0;
uint8 public playerAGamesWon = 0;
uint8 public playerBScore = 0;
uint8 public playerBGamesWon = 0;
pragma solidity ^0.4.24;
contract Calculator {
uint c;
function add(uint a, uint b) public {
c = a + b;
}
function sub(uint a, uint b) public {
var Calculator = artifacts.require('Calculator');
module.exports = function (deployer) {
deployer.deploy(Calculator);
};
var Calculator = artifacts.require("./Calculator.sol");
contract('Calculator', function (accounts) {
it("shouldn't allow division by zero", async function () {
const fail = await Calculator.new();
await fail.div(5, 0);
});
});
var Calculator = artifacts.require("./Calculator.sol");
contract('Calculator', function (accounts) {
it("shouldn't allow division by zero", async function () {
let error;
const fail = await Calculator.new();
try {
await fail.div(5, 0);
} catch (e) {
error = e;
module.exports = {
networks: {
ganache: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
},
tenderly: {
host: "127.0.0.1",
port: 9545,
pragma solidity ^0.4.24;
contract Calculator {
uint c;
function add(uint a, uint b) public {
c = a + b;
}
function sub(uint a, uint b) public {