Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2017 22:42
    @jpitts banned @etherchamp1_twitter
  • Jun 05 2016 10:33
    @chriseth banned @adamskee
Luis Schliesske
@gitpusha
As you can see I return a uint256 via
return abi.decode(returndata, (uint256));
The warning text is: Warning: Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
Normally I don't always name my return variables. I am not sure what to make of this warning. Is it better to name the return variable in my example?
Sometimes I prefer return statements to make it more visible where the frame ends.
chriseth
@chriseth
@gitpusha it seems the compiler thinks that the last line does not always revert. Can you create an issue with the full code, please?
In the meantime, you could probably rewrite it as if (!success) returndata.revert...(); return abi.decode(...):
Luis Schliesske
@gitpusha
Ok thanks
The issue is here: ethereum/solidity#10084
Baron Wilhelm Stein
@WilhelmStein

I'm making a utility that extracts such data from the debug_traceTransaction call return, so I'm looking for something more "programming/automation" oriented if you catch my drift. My first instinct is to parse the opcodes and stack contents, but when I went with that approach on trying to extract the storage data and map them to variables, I discovered the storage-layout option of the solidity compiler, which drastically helped. So, I guess I'm looking for something much neater like that.

So, any ideas anybody?

heddhshan
@heddhshan
hello, " (bool success, ) = recipient.call {value : _amount } (""); " not can exe ?
msg.sender is contract
heddhshan
@heddhshan
i got, it is " receive() external payable { }"
MohamedDenta
@MohamedDenta
when should i use payable function ?
MohamedDenta
@MohamedDenta
fundingStartBlock , fundingEndBlock in BAT Token source code ???
Mirko Staderini
@mstad
Sorry, I have a question, I hope it is not off-topic in this room. In the case please excuse me. With solc compiler we can generate json AST from a Solidity smart contract. Is there a release of solc that is able to come back from json to Solidity language?
chriseth
@chriseth
@mstad no, you can only "resume" compilation to bytecode, but not backwards to solidity source code
Mirko Staderini
@mstad
@chriseth thanks.
Edgar
@EdgarArout_twitter
why interfaces don't let me use public but only external?
swkim109
@swkim109
@EdgarArout_twitter I think because it is interface. But you can change to public by overriding.
Tezos ęś© Hunter
@TezosHunter_twitter
Hey, guys
I just made a post in the Solidity Users Google Group (https://groups.google.com/g/solidity-users/c/v1CIDO5y4iU), but i don't think it's the right or best place for the questions i asked. Can someone point me to a better place to have this discussion and get some good answers by the people involved?
matrixbot
@matrixbot

Patric > <@gitter_tezoshunter_twitter:matrix.org> Hey, guys

I just made a post in the Solidity Users Google Group (https://groups.google.com/g/solidity-users/c/v1CIDO5y4iU), but i don't think it's the right or best place for the questions i asked. Can someone point me to a better place to have this discussion and get some good answers by the people involved?

https://discord.com/invite/hbtA9ex

soham
@zemse

@chriseth Is there a syntax to call a fallback function on a contract object?

contract A {
    receive() external payable {
        revert("Random revert reason");
    }
    function test() external payable {}
}

contract B {
    A contractObj;
    function main() {
        contractObj.test{value: 1 ether}();
        contractObj.fallback{value: 1 ether}(); // looking for this
    }
}

I want to convert the below code to above kind, to be able to preserve the revert reason in the fallback message call. I want to use try catch as mentioned in docs, but seems it only works with contractObjs

(bool _success, ) = address(contractObj).call{ value:1 ether }("");
require(_success, "transfer failed for unknown reason");

or else how could I get revert reason in the .callsyntax ?

chriseth
@chriseth
the second return value is the revert reason
(bool _success, bytes memory data ) = ...
if success i true, data contains return data, if it is false, it contains the error data
Luis Schliesske
@gitpusha
Hi @chriseth - I made an observation and I wanted to ask you about it.
chriseth
@chriseth
sure!
Luis Schliesske
@gitpusha
So if a normal contract.call frame to a payable function has some msg.value
and in that contract call you make a bunch of delegatecalls
I noticed that all of the delegatecalls need to be to payable functions.
because they all use the context of msg.value which is non-zero
even if the delegatecall destination functions by themselves have no reason to accept any ether
Do you follow and is my observation accurate ?
chriseth
@chriseth
yes
do you do manual delegatecalls or library function calls?
Luis Schliesske
@gitpusha
manual ones
chriseth
@chriseth
because I think public library functions do not have this call value check exactly for that reason
Luis Schliesske
@gitpusha
yes - so it is not really a feature right? that would be my next question.
Because with my manual delegatecalls I know have to mark functions payable that I do not wish to mark payable actually.
swkim109
@swkim109
If fallback is called with calldata like abi.encodeWithSignature("foo(uint256)", _val) then foo(uin256) is called. Is it intended? I can't find the related explanation in Solidity docs.
chriseth
@chriseth
@gitpusha if you use low-level calls, you are on your own :)
@swkim109 it is impossible to call the fallback function directly in the sense that you cannot prevent the other functions from being selected if the signature matches. It is a fallback function after all
tvanepps
@tvanepps

hey all! just a reminder that @axic is giving at talk today at 14:00 ET on "The Future of Solidity" - please join us

https://live.ethonline.org

Baron Wilhelm Stein
@WilhelmStein
Hi again! Just wanted to ask a question. When analyzing a transaction trace, would you say it is a reliable tactic to look in the stack when entering a function, in order to extract the function's call data? Should I look for CALLDATALOAD opcodes instead? Any other suggestions?
adhusson
@adhusson
Is it expected that .selector doesn't work on public functions?
contract C {
    function externalIsOk() external {}
    function testExternal() external pure returns (bytes4) {
        return C.externalIsOk.selector;
    }

    function publicIsBad() public {}
    function testPublic() external pure returns (bytes4) {
        return C.publicIsBad.selector; // TypeError: Member "selector" not found or not visible (...)
    }
}
swkim109
@swkim109
@adhusson I think you'd better use this.
adhusson
@adhusson
@swkim109 I don't think it's an option when you delegatecall. Anyway, is there a good reason for not having .selector on public functions that I'm missing?
swkim109
@swkim109
@adhusson I think it is related with function visibility. It seems likeC.publicIsBad is called internally then it does not have selector.

Solidity docs says:

Note that public functions of the current contract can be used both as an internal and as an external function. To use f as an internal function, just use f, if you want to use its external form, use this.f.