Eleven01 Solidity support for Visual Studio codeSolidity is the language used in Ethereum to create smart contracts, this extension provides:
InstructionsUsing a different version of the solidity compilerSometimes you may want to use a different compiler than the one provided. All the different versions of the solidity compiler can be found in this repository: You can find all the different versions in the solc-bin repository https://github.com/ethereum/solc-bin/tree/gh-pages/bin Currently we support three ways supported to use a different version of the solidity compiler. Remote downloadTo compile using a remote version, you need to change the following user setting, with the version required, for example 'latest' or 'v0.4.3+commit.2353da71'
Using Local fileIf you don't have an internet connection, you can download the compiler and change your user settings to use this. The local file will be use instead of remote.
Npm / node installationIf you need to use an specific version for a project, you can also install solc locally in your solidity project folder.
Note: The above compilers, have an order of preference when using different settings are: Local node installation (Npm / node installation) will be used first, Local file second and finally remote. So if you just want to use the latest version of solidity for all the projects and have online connectivity all the time, use the setting:
But if you are working on an specific project using an older version, you can use npm install locally to target that specefic version, without affecting the global setting. Default project structureA default project / library dependency structure follows the DappSys library model: Libraries will have the same name as their folder they are included. Solidity files will be in the 'src' folder. Libraries will be included in the 'lib' folder. Currently there is no name conflicting resolution, so the first library found matching a name, will be the first one used. The user settings for this structure is:
OpenZeppelinIf you're using
If you have a deeper structure, like
Your user settings configuration will need to represent the full structure:
Code completionJust press Ctrl + Space or Command + Space to autocomplete statements, currently supported all the storage variables, functions and events (with snippets) included in the current document and every document in the import chain. Also supported all the global variables, global functions, types and units. Auto compilation and error highlightingAuto compilation of files and error highlighting can be enabled or disabled using user settings. Also a default delay is implemented for all the validations (compilation and linting) as solidity compilation can be slow when you have many dependencies.
LintingSolhintTo lint Solidity code you can use the Solhint linter https://github.com/protofire/solhint, the linter can be configured it using the following user settings:
This extension supports SoliumSolium is the default linter of supported by the extesion https://github.com/duaraghav8/Solium, you can configure it using the following user settings:
soliumrc.json support will be included in the near future, for specific project linting requirements. Code generation NethereumThe extension integrates with the Nethereum code generator to create Contract integration definitions. You can either generate the api for a single contract, all compiled contracts, or automatically every time you compile a smart contract solidity file. Automatic code generation and the Nethereum Code generation settings file.The simplest way is to automatically code generate your api, for this you need to create a file called "nethereum-gen.settings" at the root of your project, with the following contents.
"lang" indicates what language to generate the code, 0 = CSharp, 1 = Vb.Net and 3 = FSharp The "projectName" and "namespace" settings will be used for the manual code generation also. Single smart contract manual code generationTo code generate the Nethereum contract api from a single smart contract, you need to select the compiled "json" output file from the "bin" folder, press F1 and start typing "Solidity: Code generate" and select what language you want to generate for the current selected file. All smart contracts manual code generationTo code generate the Nethereum contract for all smart contracts already compiled, just press F1, and start typing "Solidity: Code generate" and select the option for all contracts for your desired language. Contributing / Issues / RequestsFor ideas, issues, additions, modifications please raise an issue or a pull request at https://github.com/eleven01team/e01_vscode_solidity/ and send a message on gitter at https://gitter.im/vscode-solidity/Lobby or https://gitter.im/Nethereum/Nethereum to get an instant notification. Requirements:You will need the following installed in order to use the extension: =>VS Code Version 1.32 or greater =>Node v8.x or v10.x and npm v6.x or greater =>Docker version v17.06.2-ce or greater =>Docker Compose v1.14.0 or greater =>Go version v1.12 or greater for developing Go Contracts =>java v8 for developing java contracts CreditsMany thanks to: Juanfranblanco for the vscode extension https://github.com/juanfranblanco/vscode-solidity Christian Reitwiessner and the Ethereum team for Solidity https://github.com/ethereum/solidity Raghav Dua and everyone that contributed to Solium, the solidity linter, and the solidity parser. Ilya Drabenia for creating the Solhint linter and the integration into the extension. Nexus team for the original creation of the dappfile to structure contracts in projects https://github.com/nexusdev/dapple. Beau Gunderson for contributing the initial integration of solium https://github.com/juanfranblanco/vscode-solidity/issues/24, the initial server and error mappings. Bram Hoven for starting the multiple package dependency support for different environments (node_modules, lib) Piotr Szlachciak for refactoring the syntaxes Forest Fang for providing the implementation of the "Go to definition", allowing you to navigate to structs, contracts, functions calls, etc Bernardo Vieira for adding the capability to read the solium settings from a file in the workspace root directory. Nick Addison, Elazar Gershuni, Joe Whittles, Iñigo Villalba, Thien Toan, Jonathan Carter, Stefan Lew, Nikita Savchenko, Josh Stevens, Paul Berg for their contributions. Sebastian Bürgel for keeping reminding me of the offline installation suppport David Krmpotic and Ralph Pichler for the original Sublime extension https://github.com/davidhq/SublimeEthereum Everyone for their support and feedback! |