Questions tagged [require]
The require tag has no usage guidance.
58
questions
1
vote
1answer
62 views
Functions with boolean return type while using require()
I am trying to understand the reasoning for this: (for an online class)
mapping (uint => uint) public multiplier;
/**
* Called by the owner of the TollBoothOperator.
* Can be used to update a ...
0
votes
1answer
696 views
Remix Warning : Assert
I am trying to compile a contract on remix and have run into the following warning :
Use assert(x) if you never ever want x to be false, not
in any circumstance (apart from a bug in your code). ...
1
vote
4answers
3k views
Unit testing for assert()/require() in Truffle/Solidity
If I write a function like so:
function calculate(int x) public returns (int) {
require(x > 0);
// Do other stuff
return x;
}
How would I write a JavaScript unit test in Truffle ...
2
votes
1answer
2k views
Solidity multiple vs single require
One of the functions of my smart contract can only be executed if three conditions are met. At the moment I have a single require which combines all the conditions like this:
require(evalCond1() &...
0
votes
1answer
173 views
How to add requirements to the token contract: 1) owner has enough tokens and 2) minimum sum of ETH of the receivers before updating balances
Could you check if these lines are correct and will work? In this code I have two requirements: I want to check if the owner has enough tokens (10 millions tokens) before updating balances and also ...
1
vote
0answers
269 views
Catch a “require()” in frontend
I was trying to validate a transaction with some conditions on contract level and was wondering if it was possible in any way to give user feedback in the frontend if a require() fails - aka if it ...
0
votes
3answers
202 views
Require: How to avoid users of my smart contract from losing their ether
I have a smart contract lottery that requires people to send exactly 0.2 ethers to its address in order to participate.
In the constructor:
ante = 0.2 ether;
And in the payable function
...
0
votes
1answer
297 views
Control structure with truffle (assert and require)
When I'm trying to deploy contracts that contain assert and require using truffle I receive
Error: Undeclared identifier.
e.g:
pragma solidity ^0.4.8;
contract Owned{
address public owner = ...