New answers tagged

0 votes

Creating a local variable in an if statement?

Yes. It's like other languages it won't exist in out of the scope. solc compiler give you Undeclared identifier error. for example if (everything) { uint testVariable = 1; } require(testVariable == ...
Mahdi Karami's user avatar
1 vote
Accepted

Tick range of negative tick - Uniswap v3

In Solidity, you need to add a conditional statement to implement this correctly: tickLower = tick / tickSpacing * tickSpacing; if (tick < 0 && tick % tickSpacing != 0) tickLower -= ...
kfx's user avatar
  • 1,316
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,094
2 votes

Smart contract deployment pending forever

Your Go code calculates the gas price for the contract deployment transaction incorrectly — it sets it too low. Your Go code seems okay (I think?) but maybe it fetched the gas price at the state (...
Ake's user avatar
  • 537
1 vote

Can you refer to a contract inside itself?

Yes, it is perfectly valid to call a function from the same contract using the full contract name and function name, i.e. LibOrders.cancelOrder(). This is often done to avoid name collisions, ...
Mohtajj.eth's user avatar
0 votes

Can a function call itself?

This concept is called method overriding polymorphism in OOP programming, it is achieved by making more than one function with the same name but with different parameters. It's used to change the ...
Al-Qa'qa''s user avatar
  • 253
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,094
0 votes

Can a function call itself?

You can create a function that calls itself, the issue is ensuring that you don't get stuck in an endless loop that drains all your gas. Take these contracts as an example: Assume we will always pass ...
Rohan Nero's user avatar
  • 1,094
1 vote

Can you return something only some of the time with a function in solidity?

In Solidity, a function that returns a value doesn't need to do so explicitly. For example take the following two functions: function sometimes(uint x) public pure returns(uint y) { if(x == 7) ...
Rohan Nero's user avatar
  • 1,094
1 vote

Revert inside a for loop

Yes, a revert within a loop inside a function triggers a full function revert due to its stack-based execution model, rolling back all changes made within the function.
DevCrypto's user avatar
  • 174
1 vote

Performance and Gas Implications: uint vs int in Solidity Memory Variables

The main difference between uint and int is that uint only accepts positive values, while int accepts positive and negative values. They both store a 256-bit size value and as such, have the same ...
Lejdi Prifti's user avatar
0 votes

Smart contract always returns the same hash even when provided with different input

The function isn't a view function. When you execute it it should return the transaction hash. function randomHash(uint256 externalRandom) public { bytes32 _swapID = keccak256(abi.encodePacked(msg....
Ismael's user avatar
  • 31k
1 vote
Accepted

Is it possible to define interface getters for arrays of structs?

Yes, it is possible to define a getter in an interface for an array of structs. Below is a complete example illustrating this. Interface Definition Firstly, you can define the interface with the ...
MShakeG's user avatar
  • 1,099
0 votes
Accepted

Calling performUpkeep(zeroBytes) results in 'function returned an unexpected amount of data'

Update: I was not able to fix my issue with ethers@v6. I found out that my subscription simply wasn't created. For some reason I'm unable to successfully create a subscription using this piece of code:...
r-byes's user avatar
  • 11

Top 50 recent answers are included