New answers tagged

0

Consider using OpenZeppelin Test Helper expectEvent.inConstruction. Contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.3; contract Test { address public owner; event ContractCreated(); constructor() { owner = msg.sender; emit ContractCreated(); } } truffle-test: const { expectEvent } = require('@openzeppelin/...


1

Let's take the test-contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.3; contract Test { enum Stages { stage_01, stage_02, stage_03, stage_04, stage_05 } Stages public stage = Stages.stage_01; function setStage(Stages _stage) public { stage = _stage; } } and test it such way:...


0

Basically, you need to deploy the contract to your local hardhat net just as you would to any other. That means currently you have to set up a deploy.js like in the official hardhat tutorial. I'm assuming you followed the official tutorial at least until Chapter 7: Deploying to a live network and e.g. @nomiclabs/hardhat-ethers is already properly installed. ...


1

From the example removing the {} around Web3 in the first line should do the trick const Web3 = require("web3"); const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));


1

With solc v0.8 ABIEncoderV2 is the default setting and the pragma line isn't needed anymore. See the list of breaking changes in 0.8. For testing you can inherit from the contract and implements getters there. A change required by using inheritance is declaring variables in the base contract as internal, otherwise if they are private they can't be used in ...


0

I deployed the contract in remix with different solc versions. Solc Private Public 0.8.2 439,788 609,500 0.7.6 312,372 440,476 0.6.12 308,678 436,781 There's a notable increment 160k in 0.8, but in previous version was similar 140k. Since requests returns a structure making it public requires the serialization of the structure that doesn't exists when ...


Top 50 recent answers are included