Project to test and demonstrate how to use Solidity in the browser.
- Clone the repository
- Run
npm install
- Run
npm start
- Open your browser and go to
http://localhost:3000
- Select a compiler
- Select a file to compile. Also provided is a simple JSON example.
- Compile
- The compiled code will be output.
There are some workarounds and considerations to take into account when using Solidity in the browser.
- The solc-js's node dependencies need to be polyfilled. To see the errors before polyfilling see branch without-polyfill-and-browserify
- It is not possible to load a different compiler version in the Worker. One has to terminate the worker and create a new one with the new compiler version, otherwise an error "Invalid Version" is thrown. To see the error check the branch invalid-version
To debug the code in VSCode first run it with:
npm start
Then switch to the debug tab and select Launch Chrome against localhost
and press the play button. This will open a new Chrome window with the debugger attached.