I have a static webpage and it should remain static. In this website a user generates solidity files. I would like to compile them by sending the uncompiled solidity via an api to a compiler and then receive either the compiled bytecode (potentially with warnings) or receiving an error-message if the compilation was not successful.

I do not think that I can use solc, as this article suggests, because I have a strict frontend usecase.

For instance I know that etherscan has an api that lets you verify contracts and within that verification there is of course a compilation, but there is no way to just get solidity files compiled. I know that remix.ethereum is all about compiling solidity and there seem to be some javascript libraries that do interact with it, but to my knowledge there is no (hacky or not hacky way) of sending programming code and receiving compiled code. Lastly, I could of course set up my own server and do the thing, but I'd rather not, unless there really is no other solution.

  • If by "API" you mean like a REST API, not I don't think you'll find one. You can however use solc-js, which is a javascript wrapper for solc. It is usable within the browser and includes examples in the README for doing just that
    – natewelch_
    Commented Feb 3, 2023 at 17:42
  • Thanks, yes I meant REST API. But I cannot use solc-js because it requires 'fs', which only works for nodejs if I understand correctly. At least it gives me this error message. ```Can't resolve 'fs' in '/home/myname/Projects/VotingRegistry/voting-contracts-frontend/node_modules/solc´´´.
    – Marlo
    Commented Feb 4, 2023 at 15:57

1 Answer 1


Unfortunately, there is no public API that directly allows you to send uncompiled Solidity code and receive the compiled bytecode. However, you could consider setting up your own server to compile the code.

  • Thanks @AmariS1, I'll wait to see if others might know about an API. I mean the funny thing is that it exists within the etherscan-api, but one cannot use it just by itself. It would be simple to actually expose an api just for the compilation.
    – Marlo
    Commented Feb 4, 2023 at 16:00
  • 1
    yes but actually i might have found something i am Alchemy univ student and they have this service which provides an API for compiling, deploying, and interacting with Ethereum contracts. You can use Alchemy's API to send your uncompiled Solidity code and receive the compiled bytecode or an error message. Give it a try it might be something you were looking for.
    – AmariS1
    Commented Feb 4, 2023 at 17:04
  • Thanks @AmariS1, that's cool. Couldn't find the API though, do you have a link? At least on a first glance I didn't see any compilation api on their docs docs.alchemy.com/reference/api-overview
    – Marlo
    Commented Feb 6, 2023 at 0:22
  • You can go through this link https://docs.alchemyapi.io/ This is the link to Alchemy API documentation
    – AmariS1
    Commented Feb 6, 2023 at 0:43
  • Thanks, but I do not see any endpoints for contract compilation. Maybe you can point me to the section in the docs where it is described how one creates a request to have solidity contracts compiled.
    – Marlo
    Commented Feb 6, 2023 at 0:49

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.