Skip to main content
65 votes
Accepted

What does the keyword `super` in Solidity do?

The super keyword in Solidity gives access to the immediate parent contract from which the current contract is derived. When having a contract A with a function f() that derives from B which also has ...
SCBuergel's user avatar
  • 8,784
4 votes
Accepted

What is an Internal function type variable?

Internal functions which accept function type as an argument can take internal, public and private functions when called. For example: library L { function ops( uint256 _a, uint256 ...
Nikhil's user avatar
  • 106
3 votes
Accepted

If not in the EVM, where do internal functions execute?

internal functions are called through a JUMP / JUMPI instruction, simply jumping to another point of the current code. This makes sense because internal functions do not change context (i.e., they ...
hroussille's user avatar
  • 7,901
3 votes
Accepted

Is it possible to use interface functions as types?

I asked the same question in the Solidity Matrix server, and a Solidity language developer has replied by saying that this is not currently possible. The reason being that there's no runtime type ...
Paul Razvan Berg's user avatar
3 votes

Where in the code of this unstake function is ETH actually transferred?

The BridgeRouterFacet contract's unstakeETH() function: function unstakeEth(address bridge, uint88 zethAmount) external nonReentrant onlyValidBridge(bridge) { if (...
Rohan Nero's user avatar
  • 1,745
3 votes
Accepted

What is the correlation between "Hash" (Method ID) & "Name"

This is not a Method ID (not a hash of a function name that'd be in the deployed contract) even though Etherscan shows it as Method in the UI. And that it shows as rugPullAll and even other ones if ...
Ake's user avatar
  • 1,178
3 votes

Calling private functions using Yul ( Solidity )

tl;dr, to answer your question: Is there any way at all to call private functions using inline assembly? Yes, it is possible, but not with the call() instruction. Long answer + extras: If you're ...
BonisTech's user avatar
  • 672
2 votes

DAO like functionality on Gnosis?

The Zodiac team from Gnosis is building DAO tools around the Safe. There are quite some extensions already and the community is open for new proposals. You can find more information on the Zodiac ...
Richard's user avatar
  • 5,144
2 votes

Solidity: Restrict access to functions

Yes, the modifiers will work even if the function is called inside another function. I have tested it in Remix and the function seems to work as intended, and only the owner can use it.
Kostiantyn Kurbatskyi's user avatar
2 votes
Accepted

Does a double space have an effect inside function declaration?

They are both the same. this can easily be tested in Remix by creating a contract with both methods and it will tell you that they conflict as they are parsed as the same. Even when you look at the ...
Richard's user avatar
  • 5,144
2 votes
Accepted

Private variables with public view functions

The pattern you noticed is competing with the approach of using an internal storage variable. The general idea here is you can read the variables and not write. It allows the contract to make some ...
William Entriken's user avatar
2 votes
Accepted

Why and when to user require(bool) on functions

You could, but it would not be safe because call() won't revert if the external contract execution does. It's highly discouraged and generally unsafe.
Franfran's user avatar
  • 635
2 votes
Accepted

Can solidity function have optional parameter?

It's not about Solidity, but how ethersjs abstracts the call to the contract and does some encoding and creates the transaction for you. Basically, from a js contract instance created with ethersjs, ...
Jeremy Then's user avatar
  • 4,649
2 votes

modifier vs function which method is more efficient in terms of gas?

It would depend on the code, but there wouldn't generally be much in it in terms of execution, but could be a significant different in the size of the deployed code. When the code is deployed the ...
sola24's user avatar
  • 1,248
2 votes
Accepted

modifier vs function which method is more efficient in terms of gas?

I've tested in Remix, although both function calls reverted, both methods had approximately similar execution cost (Cost only applies when called by a contract), with toDoSomething1() 23410 gas vs. ...
Yongjian P.'s user avatar
  • 4,308
2 votes
Accepted

Where are Function stored in EVM?

Basically, given a function selector, your bytecode knows where the functions are kept and use the selector to know where to jump your code to. Here is a useful link: https://blog.openzeppelin.com/...
Olivier Demeaux's user avatar
2 votes

Normal function asking to be made Payable

It's because the 'person' creation is wrong so the tx reverts. Here is the proper way: pragma solidity 0.8.16 ; contract arr { uint i = 0 ; people[] public person ; struct people ...
Olivier Demeaux's user avatar
2 votes

Does it make any sense to specify reference type function input parameters as calldata if the given function is only called contract to contract?

I am wondering however what is the point of specifying the input argument in a function as calldata, if you know that it will only be called from a contract (hence no gas savings of using the real ...
hroussille's user avatar
  • 7,901
2 votes
Accepted

The redundant `_from` parameter in the `transferFrom` function of an ERC721

Great observation on the _from parameter! I never noticed this before. Here are the two key reasons for its inclusion in the transferFrom() function in ERC-721: As you know, ERC-721 is strongly ...
Adam Boudj's user avatar
  • 2,441
2 votes
Accepted

SOLIDITY NOOB QUESTION. Is it necessary to specify that a function is a view function if it's obviously a view function?

It's not strictly necessary to specify that a function is a view function if it's already obvious from the function's code that it only reads data from the blockchain and doesn't modify it. However, ...
Mario Yahuarcani Salinas's user avatar
2 votes
Accepted

ParserError in solidity

Your code is missing the last curly bracket, which is the closing bracket for the contract Here is the updated code try this. No major changes just added a bracket at the end. // SPDX-License-...
Zartaj Afser's user avatar
  • 5,320
2 votes
Accepted

How do you use `delete` on a function?

You cannot delete a function. What you can delete, though, is a variable that points to a function. The documentation, likely, meant to say "The same happens if you call a function after using ...
Ismael's user avatar
  • 30.3k
2 votes

How to use another deployed smart contract functions?

That depends on how you want the functions to be executed. If you wish to execute them in the context of your own contract, you should look into proxies => https://docs.openzeppelin.com/upgrades-...
Nal Luksic's user avatar
  • 1,257
2 votes

Invoking a function with different amount of input than the function takes

Assuming this sub function is copied from OpenZeppelin's SafeMath.sol library, or similar. In Solidity, you can declare special library functions by declaring functions inside a library (instead of a ...
ardislu's user avatar
  • 607
2 votes

Two people calling this function at exactly the same time

Even if two transactions are created at virtually the same exact time, there will be a definite order decided upon by the miner/validator of the block where the transactions took place. This means ...
Rohan Nero's user avatar
  • 1,745
2 votes
Accepted

Possible way to hack Solidity into executing a function directly from a struct as a method? (v0.8.20)

It's a perfectly legitimate use. Only there are some restrictions: the called function must be executed within the context of the same contract. You can read the official documentation: https://docs....
Alexey Smirnov's user avatar
2 votes

Calling private functions using Yul ( Solidity )

When compiling internal and private functions, selectors are not created on them. This means that they cannot be called by passing the address of the function selector. Theoretically, you could find ...
Alexey Smirnov's user avatar
2 votes

Calling private functions using Yul ( Solidity )

This is not possible. As Alexey said, a function selector is not created for private variables. Whenever someone calls a solidity smart contract, the first thing that contract does is figure out where ...
Patrick Collins's user avatar
1 vote
Accepted

If the smart contract does not include the withdrawal function, will that ether be stored in the smart contract for life?

If the smart contract does not include the ability to send ether to other people, will that ether be stored in the smart contract for life? Yes. Another way to withdraw is to add functionality for ...
Mikko Ohtamaa's user avatar
1 vote
Accepted

Function cannot be declared as view because this expression (potentially) modifies the state

There are a few different perspectives into this. Let's see. Blockchain's perspective The blockchain basically just stores data. Data can be read from any node. State changes aren't free, reading data ...
Lauri Peltonen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible