Visual Studio Code language support extension for Solidity smart contracts in Ethereum

Juan Blanco 885da8ef0f Retry and performance improvement 2 months ago
.vscode e056030ed5 Removing the remix-util dependency and truffle-workflow-compile 1 year ago
images 385b22791b Adding icon 5 years ago
screenshots 186308a128 Readme update with new instructions 2 months ago
snippets f4c3952159 Adding erc approved, draft and uniswap snippets 2 months ago
src 885da8ef0f Retry and performance improvement 2 months ago
syntaxes 07fbc4efa5 Adding extra autocomplete and syntax highlighting 7 months ago
.gitattributes 2f3f9d5bb8 :space_invader: Added .gitattributes & .gitignore files 5 years ago
.gitignore 9ef5f971c2 Add tests fot trufstuf 1 year ago
.vscodeignore d271eb0cbe Upgrade to new Typescript and Solidity 3 years ago
Licence.txt 307c00e587 New syntaxes in Json 4 years ago
README-DEVELOP.md 90795364f5 Upgrading the code generator and develop instructions 1 year ago
README.md d9c680ecd5 Forgot to save... 2 months ago
package.json 59f3e14d58 Removing deprecated linter settings and simplify the input 2 months ago
solidity-0.0.64.vsix 299fa4efeb Returning compiledResults 1 year ago
solidity-0.0.66.vsix 08daaa77ff New context menus and code generators for .Net 8 months ago
solidity-0.0.67.vsix 08daaa77ff New context menus and code generators for .Net 8 months ago
solidity-0.0.69.vsix 08daaa77ff New context menus and code generators for .Net 8 months ago
solidity-0.0.70.vsix dda24fef1d Ensure abi is parsed to follow the flow 8 months ago
solidity-0.0.71.vsix 524284b1be Caching and removing check compiler on init to help WSL users 5 months ago
solidity-0.0.72.vsix f32139dae1 adding 0.72 7 months ago
solidity-0.0.73.vsix 7406602f23 Upgrading solhing to 3.0.0 5 months ago
solidity-0.0.74.vsix 574e98311a Upgrades and simple fix for solhint plugins 4 months ago
solidity-0.0.75.vsix 885da8ef0f Retry and performance improvement 2 months ago
solidity.configuration.json c37d0d6412 Completion Service 3 years ago
tsconfig.json b1a4d6dc54 Migrate analyze to api v1 1 year ago
tslint.json 6b4f44e463 Compiler random folder support and solium checks 1 year ago

README-DEVELOP.md

Table of Contents

Perhaps you want to help work on this awesome project? Or run from the github repository?

Prerequisites...

You need to have installed

There are a number of nodejs packages are needed, like typescript, but you can get those via npm, which is described in a below section.

Dependency hell / Current Issues

There is a dependency on isomorphic-fetch if having issues compiling, replace the index.d.ts file with this

declare namespace _fetch { }
declare const _fetch: any;
export = _fetch;

How to run code in this github repository

Clone the repository:

$ git clone https://github.com/juanfranblanco/vscode-solidity
Cloning into 'vscode-solidity'...
remote: Enumerating objects: 169, done.
...
$ cd vscode-solidity
$

Install dependent npm packages:

$ npm install

Now just run from inside the vscode-solidity folder

$ code .

Running

If you just want to run the code, on the top there is a "Debug" menu item and under that, the second item is "Start Without Debugging", which is also bound the key sequence Ctrl-F5.

After that, the VSCode window should turn from blue to orange and another window will pop up. In this window you will have the vscode extension installed and enabled.

If you edit a solidity file, which is a file ending in .sol and looks like this:

/*
 * @source: http://blockchain.unica.it/projects/ethereum-survey/attacks.html#simpledao
 * @author: Atzei N., Bartoletti M., Cimoli T
 * Modified by Josselin Feist
 */
pragma solidity 0.4.25;

contract SimpleDAO {
  mapping (address => uint) public credit;

  function donate(address to) payable public{
    credit[to] += msg.value;
  }

  function withdraw(uint amount) public{
    if (credit[msg.sender]>= amount) {
      require(msg.sender.call.value(amount)());
      credit[msg.sender]-=amount;
    }
  }

  function queryCredit(address to) view public returns(uint){
    return credit[to];
  }
}

This when rendered inside be colorized, for example the tokens "pragma", "solidity" and "0.4.25" may appear in a different color. If the all appear in the same color then the language extension mechanism is not working and there is probably something wrong in the extension. Look in the other VSCode window with the orange frame for what might be wrong.

But if everything is good, enter Ctrl-Shift-P and a list of commands will pop up. If you type "Solidity", you should see those specific to this extension.

Debugging

You may want to extend this code of may find a problem and want to debug what is going wrong. For this, you start off from the "Debug" menu using the first item on the list "Start Debugging" which is also bound to the function key F5. As before the window will go orange a popup menu bar will appear at the top.

NOTE: It may happen that after the window goes orange, another and VSCode window with the blue, the "play button" may go from a the parallel bars to "pause" back to "play". When that happens you may also be stopped in bootstrap-fork.js at some nonsensical like like line 9 which has no code on it. If this happens (and it may happen several times for each solidity file loaded) just hit the play button to make sure it goes back to the parallel bars. You have 10 seconds from the time this button goes from "Pause" to "Play" to hit the "Play" button. Otherwise in the other VSCode you will get a popup message that reads:

Extension host did not start in 10 seconds, it might be stopped on the first line and needs a debugger to continue.

See also: