2

Everytime I try brownie compile I see this:

SolcInstallationError: Downloaded binary would not execute, or returned unexpected output. If this issue persists, you can try to compile from source code using `solcx.compile_solc('0.5.17')`.

I can not for the life of me figure out how to fix this error I am getting. I've read so many posts and tried so many things but I can't get it to work.

  • I started using Python 3.9 in my virtualenv based on another post saying that is what worked best
  • Dozens of various attempts to brew uninstall, brew install various things.
  • paired that with brownie 1.19.3 -- that'd didn't help either.
  • I've tried pretty much anything you can imagine with solc, and that has not helped.
  • I've changed my version of solidity several times, no luck either.

I've tried so many things to fix this but I can't find an answer!

Here is the full error that I see in my terminal, and then I've also posted under this my .sol .yaml .py files.

Brownie v1.19.3 - Python development framework for Ethereum

Downloading from https://solc-bin.ethereum.org/macosx-amd64/solc-macosx-amd64-v0.5.17+commit.d19bba13
100%|█████████████████████████████████████| 30.4M/30.4M [00:27<00:00, 1.09MiB/s]
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/compile.py", line 50, in main
    proj = project.load()
  File "brownie/project/main.py", line 780, in load
    return Project(name, project_path)
  File "brownie/project/main.py", line 188, in __init__
    self.load()
  File "brownie/project/main.py", line 257, in load
    self._compile(changed, self._compiler_config, False)
  File "brownie/project/main.py", line 100, in _compile
    build_json = compiler.compile_and_format(
  File "brownie/project/compiler/__init__.py", line 121, in compile_and_format
    set_solc_version(version)
  File "brownie/project/compiler/solidity.py", line 97, in set_solc_version
    install_solc(version)
  File "brownie/project/compiler/solidity.py", line 105, in install_solc
    solcx.install_solc(version, show_progress=True)
  File "solcx/install.py", line 466, in install_solc
    raise exc
  File "solcx/install.py", line 459, in install_solc
    _validate_installation(version, solcx_binary_path)
  File "solcx/install.py", line 636, in _validate_installation
    raise SolcInstallationError(
SolcInstallationError: Downloaded binary would not execute, or returned unexpected output. If this issue persists, you can try to compile from source code using `solcx.compile_solc('0.5.17')`.

Here is my brownie-config.yaml file (when I type which solc into my terminal, this is the path I see)

compiler:
  solc:
    version: 0.5.17
    paths:
      - /opt/homebrew/bin/solc


networks:
  default: polygon-zkevm-testnet
  polygon-zkevm-testnet:
    chainid: 1442
    host: https://rpc.public.zkevm-test.net
    explorer: https://testnet-zkevm.polygonscan.com
    accounts:
      from_key: ${PRIVATE_KEY}
      from_mnemonic: ${MNEMONIC}

Here is my .sol file

// SPDX-License-Identifier: MIT
pragma solidity ^0.5.17;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Capped.sol";


contract LoyaltyRewards is ERC20 {
    address public owner;

    constructor() ERC20("LoyaltyToken", "LOYAL") {
        owner = msg.sender;
        _mint(msg.sender, 1000000 * 10**decimals());
    }

    function mint(address to, uint256 amount) public {
        require(msg.sender == owner, "Only owner can mint tokens");
        _mint(to, amount);
    }
}

Here is my deploy.py file.

from brownie import LoyaltyRewards, accounts, network, config

def main():
    dev = accounts.add(config['wallets']['from_key'])
    print(f"Deploying to {network.show_active()} using account: {dev}")

    # Deploy the LoyaltyRewards smart contract
    loyalty_rewards = LoyaltyRewards.deploy({'from': dev})
    print(f"LoyaltyRewards contract deployed to: {loyalty_rewards.address}")
1

1 Answer 1

0

I had the same issue, and i solved it by downloading visual studio 2017 build tools + running install_deps.bat https://docs.soliditylang.org/en/v0.5.10/installing-solidity.html#building-from-source

Than close and re-open the terminal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.