All Questions
Tagged with visibility solidity
17 questions
0
votes
1
answer
265
views
Can you change an overridden function's visibility/mutability?
Say I have a parent and a child contract, in the child I don't want to use one of the parent's functions, so I changed the logic to just revert if it is ever called.
Now the terminal output shows me ...
1
vote
0
answers
73
views
Explicitly linked Solidity libraries produce bigger contract size than having it embedded
If I replace all the library functions' visibility to either external or public, I will have to deploy the libraries separately first, and then explicitly link them in the contract which is using them....
0
votes
0
answers
31
views
Function Visibility specifiers during inheritance
when am overriding a function in solidity must my child function have the same visibility as the parent function? can the parent function be public and the child function be internal
0
votes
2
answers
733
views
Why gas prices vary according to state visibility (public/external/private/internal)?
Why gas prices vary according to state visibility(public/external/private/internal) to Function?
0
votes
1
answer
38
views
wrapper getter functions
OpenZeppelin's ERC20 token contract contains the following declaration of decimals, and then a getter function for accessing that variable:
uint8 private decimals;
function decimals() public view ...
1
vote
1
answer
320
views
Solidity private/internal function call from external function
what the purpose of that way to restrict access to function call?
function updateQuorumNumerator(uint256 newQuorumNumerator) external virtual onlyGovernance {
_updateQuorumNumerator(...
0
votes
1
answer
72
views
Why no private constructors in solidity?
I am looking for a mechanism that allows me to restrict the creation of a contract A from anywhere but another contract B.
contract A {
// ...
}
contract B {
constructor() {
A a = new ...
1
vote
1
answer
68
views
Which one is better visibility option of solidity method?
I have a external method declared. At some point I realized that I need to call that external method from one of the another method within a contract and which is not possible. There are options to ...
6
votes
1
answer
519
views
Is it safe to mark library functions that modify the calling contract's state as public in Solidity?
I am using libraries to reduce the cost of deployment of a contract of which there may be many instances (using a factory contract). When I mark a library function as internal, the code seems to get ...
8
votes
2
answers
15k
views
What are private variables in solidity?
The following variables here, assuming solidity 4.24 or later.
mapping(something => something) private yourmapping;
bool private yourbool;
address private youraddress;
uint256 private ...
3
votes
2
answers
1k
views
What is an example of when a solidity variable must NOT be public? Where it would break the security of the contract?
I'm really struggling to understand variable visibility. I'm aware that everything is public on a blockchain. Yes you can make a variable private to make it invisible to other contracts, but so what? ...
1
vote
1
answer
190
views
When does it make sense to use `this.f()` instead of making the function public?
In external vs public best practices, Tjaden Hess says that:
It almost never makes sense to use the this.f() pattern, as this requires a real CALL to be executed, which is expensive
So why does ...
1
vote
1
answer
170
views
Unit test compilation failed due member not found or not visible
I have written an unit test but when I launch it I get following error:
Test.sol:25:22: TypeError:
Member "val1" not found or not visible after argument-dependent lookup in function () view external ...
4
votes
1
answer
458
views
What are function types in Solidity used for?
Can you provide an example of when and why you would want to define and use a function type, as a opposed to simply calling a function?
I understand how from here: https://ethereum.stackexchange.com/...
4
votes
3
answers
2k
views
Accessing not public variables
Is it possible as the creater of the smart contract to access a not public variable? E.g.:
contract MyContract {
uint256 someLevel;
function changeLevel(uint _newLevel) public {
...
0
votes
1
answer
1k
views
Calling External Contract Function with Modifiers - Results in Unknown Error
I am attempting to call an external contract function, but modifier on the function is throwing an error. And I can't figure out why. Any help is appreciated! Info is below:
I have two contracts:
...
2
votes
1
answer
741
views
Why are parameters of external functions not lvalue types?
When a function's visibility is external, trying to modify the function parameters within that function gives the error:
TypeError: Expression has to be an lvalue.
However, if I change the ...