Questions tagged [return]
The return tag has no usage guidance.
11
questions
0
votes
1
answer
10
views
Do you have to explicitly state in the body of a function that it should return something?
I'm looking at the following function which is supposed to return (uint8 id, uint8 nextId). I see that in the body of the function, the return statement is within an "else" statement - see ...
1
vote
1
answer
15
views
Can you return something only some of the time with a function in solidity?
I am looking at a function that says it returns two uints, but the return statement is inside an else statement, so obviously there are conditions under which nothing would be returned. Can you have ...
1
vote
1
answer
33
views
How do RETURN and MLOAD work for high offsets?
When trying to load the 32 bytes of memory that follow a high offset (say 0x12345678), the RETURN and MLOAD opcodes give an out of gas error. Why is that ?
Example
PUSH1 0x20
PUSH4 0x12345678
RETURN
...
1
vote
1
answer
77
views
object returned for uint256 return value
I implemented a method to retrieve a price for a currency via some chainlink price feed. This price is casted to an uint256. But if I call this method via etherscan it does not show a number, but just ...
1
vote
1
answer
215
views
Is there no return value in the result of a transaction using ethersjs?
The Solidity example code :
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract Test {
uint256 testvalue;
function testFunc(uint amount) public returns(uint) {
testvalue = ...
3
votes
2
answers
938
views
Why does SafeERC20 assume that the token's transfer and transferFrom return value is optional?
In openZeppelin's SafeERC20, the functions safeTransfer and safeTransferFrom call an internal function called _callOptionalReturn, which makes a low-level call to the token's transfer and transferFrom ...
1
vote
1
answer
18
views
Different number of arguments in the return statement with event -
Here is my code, dailyquotes event has 2 arguments and so does return statement, then why the error?
pragma solidity >0.7.0 < 0.9.0;
// SPDX-License-Identifier: open
contract Letscode{
...
2
votes
2
answers
32
views
Difference between
I am going through Patrick Collins' course on Youtube and was confused why the following code works. Separate from the low-level stuff he's doing here, why does getSelectorOne() work in the ...
1
vote
0
answers
58
views
Basic function returns 0x0000000000000
I'm trying to learn Soliity and started with a basic api.
I pass the parameters of the function
(from here I got the format of the parameters https://market.link/nodes/5fcd7b71-33aa-4679-bc70-...
1
vote
1
answer
220
views
Retrieve a non-constant/non-view transaction's return (output) data with hardhat/ethersjs
I'm trying to figure out if it's possible to retrieve the return value of a non-view function. Specifically, I want to see the return value of a newly created contract
I have created a simple setup to ...
1
vote
0
answers
528
views
returning struct in solidity
I have seen here that we can return struct for internal functions.
Why can we not just return struct for a non-internal (= public) function?
Also, I can see in the same link "structs would have ...