Questions tagged [modifiers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5
votes
1answer
3k views

Override parent method and modifiers

For example, we have a contract: contract A { modifier checkCaller() { require(msg.sender == 0x123); _; } function doSmth() checkCaller {} } We make child contract and ...
2
votes
2answers
664 views

Could not compile source code. Expected primary expression in modifier onlyAdmin

Why do i get this error message? Code: pragma solidity 0.4.8; contract Adminstrator { address public admin; function Adminstrator() { admin = msg.sender; modifier onlyAdmin() { ...
0
votes
1answer
278 views

Modifiers misunderstanding

pragma solidity ^0.4.0; contract test { bool test_bool1 = false; bool test_bool2 = true; modifier test_modifier(bool _test_bool){ if (_test_bool == false) throw; _; } ...
1
vote
1answer
110 views

Splitter contact: is payable modifier missing?

I am using the geth javascript console, trying to split pre-fork ETH using the ReplaySafeSplit v2 contract 0xaBbb6bEbFA05aA13e908EaA492Bd7a8343760477 (code here). I am doing this as follows: ...
0
votes
1answer
458 views

On Solidity, calling event from modifier seems to fail

Two modifiers on a contract throw an "Exception during execution. (invalid opcode)." error when not being satisfied as expected. Both of them are calling an event when the condition they check is not ...
1
vote
1answer
376 views

Solidity: Invert modifers?

I can already implement a basic onlyOwner modifier. But what if I have an onlyOwner modifer already in my function and I want to specify that a function can be called by anyone other than the owner in ...
5
votes
2answers
298 views

Solidity: Can modifiers be marked payable?

Can I have a modifier that enforces the amount sent by a user in a call to a function, and if it is below a certain amount, throw? I want to do something like the following: uint256 n; // Set some ...
3
votes
2answers
2k views

How the contract storage data saved in blockchain?

contract { mapping (bytes32 => uint256) private balances; function setValue(uint256 a) { uint index = sha3(msg.sender); balances[index] = a; } } I put a "private" before balances , ...
0
votes
1answer
91 views

Modifer Inheritance, Unexpected Result

The setup of the contracts has 3 contracts: a library contract, a Controller contract with modifiers and a main contract as follows: DataSet.sol library DataSet { struct IndexValue { uint ...
1
vote
2answers
158 views

Function modifier seems to be not working

I have a simple contract as below. pragma solidity ^0.4.9; /* Contract accepting ethers during 10 minutes */ contract SimpleBidding { address receivingAccount; uint deadline; struct ...
4
votes
1answer
510 views

Will payable modifier throw if no ether is sent to it?

Should I add a check to make sure Ether was sent along with the transaction or is that redundant?
14
votes
1answer
1k views

Bad Jump Destination error

I wrote what I thought was a dead simple contract - a saving jar... you add value ("save") into the jar and when the balance of the contract reaches a certain amount ("target"), then I am able to ...
4
votes
1answer
286 views

Use modifier function to create heirachy of smart contracts

I have 3 contracts that I want to implement. The contracts are master , admin and customer. So the master contract is initiated by a single person, the owner of the private chain (based on geth). The ...
2
votes
2answers
259 views

Modifiers causing internal compilation error

My modifiers are throwing internal compilation errors: Internal compiler error: Identifier type not expected in expression context. modifier critical { if (mutex) throw; mutex = true; _; ...
2
votes
1answer
130 views

Is it possible to use a modifier so that certain functions can only be executed by the contract, itself?

How can you program a contract so certain functions can only be called by other functions within the contract? Would you use a modifier? In the example below I'd want a user to have to call ...
6
votes
1answer
649 views

Why use throw in modifiers instead of conditional entrance?

Almost every tutorial advises a code like this for a permission modifier. modifier isAdmin() { if(msg.sender != owner) { throw; } _ } But wouldn't it be simpler to use it without ...
17
votes
2answers
5k views

Can Solidity function modifiers access function arguments?

I would like to have a modifier that looks like this: modifier restrictTargetType(uint contractType) { if (contractTypes[target] != contractType) { throw; } _ } Where target is an address ...
41
votes
1answer
10k views

Are underscores `_` in modifiers code or are they just meant to look cool?

I often see _ in modifiers modifier onlyOwner() { if (msg.sender != owner) throw; _ } Does it execute any code or is it meant to make the code easier to read ?
3
votes
1answer
151 views

How to create modifers for permissioned access

I have a citizenship persona contract which acts as a personal identity file which is under the control of the user. Personas can make other personas in the system into trustees or allies. As part of ...

1
2