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
chriseth
@chriseth
you can request the generated sources - it is one of the artefacts in standard-json
"evm.deployedBytecode.generatedSources" - "evm.bytecode.generatedSources"
Peteris Erins
@Pet3ris
when asking for the "ast" for regular sources, they seem to have an "id" element, whereas the generatedSources AST doesn't
otherwise there are similarities between both, e.g., they have nodeType, src, name, etc.
Cody Marx Bailey
@superphly
How do you guys suggest I manage different versions of solc on a Mac? I’m trying to use Trail of Bits docker thing, but it’s cumbersome and I’m getting all kinds of errors. I’ve looked at some web3j/svm but it’s not looking that strong.
Right now I have solcjs installed via NPM, but it doesn’t give me an option to swap out different solc versions, much less let me run solc naked.
I was using brew, but it doesn’t allow me (as far as I know) to install older versions.
Peteris Erins
@Pet3ris
You can do older versions with brew like so brew install solidity@5, brew install solidity@6 and then link between them: brew unlink solidity@5, brew link solidity@6. I'm not sure if you can go more granular than the latest for each major version though.
chriseth
@chriseth
@Pet3ris the generated sources are yul, so they should be similar to the ast of inline assembly.
@superphly you can download macos binaries from here: https://binaries.soliditylang.org/macosx-amd64/list.txt
Hakeem Orewole
@eltNEG

Please how can I initiate a create2 contract for a contract that has no constructor?

D d = new D{salt: salt}(); ==> This does not generate a predictable address for me

D d = new D{salt: salt}; ==> TypeError: Type function () returns (contract D) is not implicitly convertible to expected type contract D

I have tried the above for the example given here here: https://docs.soliditylang.org/en/v0.8.0/control-structures.html#salted-contract-creations-create2

Hakeem Orewole
@eltNEG
^^ It works. I am the one making a mistake.
Hakeem Orewole
@eltNEG

Can someone please tell what I am doing wrong. I have a contract WalletSpender that is created by a factory contract (snippets below).
The bytecode for WalletSpender generated for me by truffle solc version: "0.6.10" is different from the one returned by getCreationCode

contract WalletSpender is IWalletSpender {

    function spendToken(address _token, address _to, uint256 _value, address _feeReceiver, uint256 _fee) external override returns (bool success) {
        IERC20 token = IERC20(_token);
        if(_feeReceiver != address(0)){
            token.transfer(_feeReceiver, _fee);
        }
        token.transfer(_to, _value);
        return true;
    }

    function destroy(address payable _to) external override returns (bool success) {
        selfdestruct(_to);
        return true;
    }

}

The factory:

contract WalletFactory is IWalletFactory {
    function calcSpenderAddress(uint256 salt) view external returns(address, address, address, bytes32)  {
        bytes32 newsalt = keccak256(abi.encode(_msgSender(), salt));
        address predictedAddress = address(uint160(uint(keccak256(abi.encodePacked(
            bytes1(0xff),
            address(this),
            newsalt,
            keccak256(type(WalletSpender).creationCode)
        )))));
        return (predictedAddress, address(this), _msgSender(), newsalt);
    }

    function getCreationCode() pure external returns(bytes memory)  {
        return type(WalletSpender).creationCode;
    }
}
Bytecode returned by contract
0x608060405234801561001057600080fd5b50610366806100206000396000f3fe608060405234801561001057600080fd5b50600436106100355760003560e01c8062f55d9d1461003a5780632142b23414610096575b600080fd5b61007c6004803603602081101561005057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610146565b604051808215151515815260200191505060405180910390f35b61012c600480360360a08110156100ac57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610161565b604051808215151515815260200191505060405180910390f35b60008173ffffffffffffffffffffffffffffffffffffffff16ff5b600080869050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161461025f578073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561022257600080fd5b505af1158015610236573d6000803e3d6000fd5b505050506040513d602081101561024c57600080fd5b8101908080519060200190929190505050505b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87876040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156102e657600080fd5b505af11580156102fa573d6000803e3d6000fd5b505050506040513d602081101561031057600080fd5b81019080805190602001909291905050505060019150509594505050505056fea26469706673582212202d2b34bc9efdc5e9791e4e99201f55db8bd40eb9328210b751f0e0abfb4b611864736f6c634300060a0033
Truffle's bytecode:
0x608060405234801561001057600080fd5b50610366806100206000396000f3fe608060405234801561001057600080fd5b50600436106100355760003560e01c8062f55d9d1461003a5780632142b23414610096575b600080fd5b61007c6004803603602081101561005057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610146565b604051808215151515815260200191505060405180910390f35b61012c600480360360a08110156100ac57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610161565b604051808215151515815260200191505060405180910390f35b60008173ffffffffffffffffffffffffffffffffffffffff16ff5b600080869050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161461025f578073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b15801561022257600080fd5b505af1158015610236573d6000803e3d6000fd5b505050506040513d602081101561024c57600080fd5b8101908080519060200190929190505050505b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb87876040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156102e657600080fd5b505af11580156102fa573d6000803e3d6000fd5b505050506040513d602081101561031057600080fd5b81019080805190602001909291905050505060019150509594505050505056fea2646970667358221220adae6e2d3aff5891b9c8d09e2ca4b40f6eb5690ddea3bd935aca4fd51138609064736f6c634300060a0033
The difference occurred towards the end of the bytecode
chriseth
@chriseth
@eltNEG the last ~40 bytes is the metadata hash. It can be different if you modify the source (even whitespace), if you use different compiler settings or different file or path names during compilation.
Hakeem Orewole
@eltNEG
Thank you @chriseth
Saikat Sarkar
@saikat041
Can somebody help me in building the solidity from source. I followed the docs but failed to build it.
@chriseth
The problem is related to the boost library
chriseth
@chriseth
@saikat041 which operating system are you on? What is the exact error? Which boost version do you have installed?
Climb Yang
@yp945
When I read the solidty documentation, I found that the following code cannot be executed normally
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;

contract Test {
    // This function is called for all messages sent to
    // this contract (there is no other function).
    // Sending Ether to this contract will cause an exception,
    // because the fallback function does not have the `payable`
    // modifier.
    fallback() external { x = 1; }
    uint x;
}

contract TestPayable {
    // This function is called for all messages sent to
    // this contract, except plain Ether transfers
    // (there is no other function except the receive function).
    // Any call with non-empty calldata to this contract will execute
    // the fallback function (even if Ether is sent along with the call).
    fallback() external payable { x = 1; y = msg.value; }

    // This function is called for plain Ether transfers, i.e.
    // for every call with empty calldata.
    receive() external payable { x = 2; y = msg.value; }
    uint x;
    uint y;
}

contract Caller {
    function callTest(Test test) public returns (bool) {
        (bool success,) = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));
        require(success);
        // results in test.x becoming == 1.

        // address(test) will not allow to call ``send`` directly, since ``test`` has no payable
        // fallback function.
        // It has to be converted to the ``address payable`` type to even allow calling ``send`` on it.
        address payable testPayable = payable(address(test));

        // If someone sends Ether to that contract,
        // the transfer will fail, i.e. this returns false here.
        return testPayable.send(2 ether);
    }

    function callTestPayable(TestPayable test) public returns (bool) {
        (bool success,) = address(test).call(abi.encodeWithSignature("nonExistingFunction()"));
        require(success);
        // results in test.x becoming == 1 and test.y becoming 0.
        (success,) = address(test).call{value: 1}(abi.encodeWithSignature("nonExistingFunction()"));
        require(success);
        // results in test.x becoming == 1 and test.y becoming 1.

        // If someone sends Ether to that contract, the receive function in TestPayable will be called.
        require(payable(test).send(2 ether));
        // results in test.x becoming == 2 and test.y becoming 2 ether.

        return true;
    }
}
Can someone please check it out? I found that calling fallback through the transfer function will fail
Climb Yang
@yp945
First, this Caller contract did not accept the function of ether, and then when I added the function of accepting ether, I transferred ether to the contract, and then called the callTestPayable function, which still failed.
Saikat Sarkar
@saikat041

@saikat041 which operating system are you on? What is the exact error? Which boost version do you have installed?

@chriseth I am using windows 10, and I downloaded prebuilt boost 1.67 using the install _deps.bat.

I am getting following error:
PS C:\Users\saika\solidity\build1> cmake -G "Visual Studio 16 2019" ..
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29336.0
-- The CXX compiler identification is MSVC 19.28.29336.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
  Could NOT find Boost (missing: filesystem unit_test_framework
  program_options system) (found suitable version "1.67.0", minimum required
  is "1.65.0")
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.19/Modules/FindBoost.cmake:2193 (find_package_handle_standard_args)
  cmake/EthDependencies.cmake:34 (find_package)
  CMakeLists.txt:42 (include)


-- Configuring incomplete, errors occurred!
See also "C:/Users/saika/solidity/build1/CMakeFiles/CMakeOutput.log".
chriseth
@chriseth
@yp945 you are right, the receive and fallback functions use too much gas.
chriseth
@chriseth
@yp945 here is the fix: ethereum/solidity#10824
Kamil Śliwak
@cameel
@saikat041 It's complaining that your installation of the Boost library is missing some of the required libraries. How did you install it?
Saikat Sarkar
@saikat041
@cameel first I ran the install_deps.bat for installing boost. But this did not work. Then I tried installing boost manually by following boost docs.
Sam Richards
@samajammin

Heya folks! We’ve been working on some updates to the ethereum.org homepage which you can see here: https://60087128e474c647250d0c89--ethereumorg.netlify.app/en/

Keen to hear your thoughts around the code examples - check out the "new frontier for development" section. We've included 2 smart contracts - a simple token & a basic DNS registry.

We’re all ears if you have ideas on 1) improvements to those code examples 2) better (simple!) code examples that you feel help demonstrate the capabilities of Ethereum or 3) if you have any other input on the page :slight_smile: Thanks in advance!

Kamil Śliwak
@cameel
@saikat041 Did you also follow steps to build the binary libraries? The missing libraries that the error message mentions are exactly those I would expect if you had a header-only installation.
The instructions I'm linking to also have a simple test program that you can compile to verify that boost itself is installed properly. Could you try that?
By the way, this should not affect whether this compiles or not but you're using boost 1.67.0 which is quite old at this point. You're installing it yourself anyway so I'd suggest using the latest one (1.75.0)
Kamil Śliwak
@cameel
Could you also tell me what exactly happens when you try to run install_deps.bat? If it's a bug we'd like to fix it.
Note that there's also install_deps.ps1 (using PowerShell). See if that one works for you.
Saikat Sarkar
@saikat041
@cameel When I ran install_deps.bat it downloaded boost into deps folder. Then I ran cmake -G "Visual Studio 16 2019" .. and I got the following error
CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message): Could NOT find Boost (missing: filesystem unit_test_framework program_options system) (found suitable version "1.67.0", minimum required is "1.65.0")
I could not run install_deps.ps1 as running scripts is disabled in my pc.
Kamil Śliwak
@cameel
@saikat041 Hmm... Interesting. So it's the same error you're getting after installing it manually.
If your system has some limitations imposed by an administrator then maybe in both cases the problem is that Boost fails to install the binary libaries in the directory where they usually go?
So what about the binary libraries? Did you build them according to Boost installation instructions?
If you're sure you have these libraries, you could try to force CMake to use them by adding -DBOOST_ROOT:PATHNAME="PUT YOUR BOOST INSTALL PATH HERE" -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_NO_SYSTEM_PATHS=TRUE to the cmake invocation.
You should of course replace PUT YOUR BOOST INSTALL PATH HERE with Boost path on your system.
Stefano Franzoni
@StefanoFranz20_twitter

Hello, I write the following contract https://codeshare.io/2EdB3O and I'm interacting with it using a react application.

  • when I invoke the registerOwner function, after a couple of times that work without problems, the transaction (signed by metamask) raises the following alert "ALERT: Transaction Error. The exception is thrown in contract code"
  • I increased the gas passed during the method call and the alert did not appear anymore. Anyway, the transaction raises a new exception.
  • MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32000,"message":"exceeds block gas limit"}}'

There's someone that knows how to fix it?

chriseth
@chriseth
block gas limit is the maximum amount of gas per block. no transaction can use more gas than this number.
adam000034
@adam000034
if I change the genesis block do I have to restart my whole testnet?
Hassaan Ahmed
@murtrax
What is the group's opinion on the up and coming side chain and rollup solutions that promise greater transaction throughput and lower costs. Is it a better solution to alternative blockchains such as Binance Smart chain and Polkadot.
1 reply
Lauri Peltonen
@microbecode
side chains are a good solution if you want to stay in the Ethereum ecosystem. Switching to an entirely other blockchain is a big change
Hassaan Ahmed
@murtrax
Yeah but something like binance smart chain has a very similar development process to ethereum. Since it's basically a clone of the ethereum network no? Also what sidechains is currently viewed as the best solution? Any insight on that
Baron Wilhelm Stein
@WilhelmStein
Hey guys! I wrote a utility that can visually depict (solidity code highlighting) what transpired during a transaction towards a solidity smart contract. It's here if any of you are interested. Please do not hesitate to tell me what I can add/change (though I do not know how much support I will provide in the future). Cheers!
chriseth
@chriseth
@WilhelmStein that sounds great! Do you have a demo? Also: Have you considered using https://sourcify.dev/ to auto-retrieve the source code of a contract?
Baron Wilhelm Stein
@WilhelmStein
@chriseth my thesis pdf contains a "demo" and explains how it all works. I'll link it in the readme, though the link will be down until the online-library I published it at fixes their internal server errors. Regarding sourcify, I didn't know that was a thing. I'll take a look.