Connect to a network using the Truffle extension for Visual Studio Code¶
You can connect to a Quorum Blockchain Service (QBS) network using the Truffle extension for Visual Studio Code (VS Code), which allows you to deploy smart contracts to QBS using the complete IDE environment of VS Code and securely sign your transactions using the Truffle Dashboard and MetaMask.
Open VS Code, navigate to the Marketplace tab, search for
truffle, and select Install.
Once the extension is installed, select View from the top toolbar, and select Output. In the Output window, select the Truffle for VSCode item.
This may yield an error that some requirements for the extension are not installed on your system. If this occurs, you can install the dependencies by selecting them inside VS Code, which navigates you to the download pages for the missing components.
When installing each component, refer to the Truffle documentation on any configurations necessary during installation. See the following links for more information:
- Node.js installation. Note these instructions also install the VS 2019 build tools which prompts a Powershell window to complete installation. This installation may take a few minutes to complete.
- NPM is installed as a part of Node.js, so a separate installation isn’t necessary.
- Truffle and Ganache install within VS Code when you select their respective buttons.
Download a sample smart contract by opening View on the toolbar, selecting Command Palette, selecting Truffle: New Solidity Project, and then selecting Create basic project from the command list. You must create your project in an empty directory.
Once completed, you will see your project with the scaffolding needed to build and deploy your smart contract to QBS.
The Truffle Dashboard uses MetaMask to connect to your QBS network and securely sign transactions.
Start the Truffle Dashboard by opening a new terminal window in Powershell and executing
The Truffle Dashboard opens a new browser window and asks you to connect MetaMask to the browser instance. Select Connect Wallet and MetaMask opens a confirmation window.
Make sure you’re connected to the QBS Network you configured in the MetaMask guide.
Now that you configured MetaMask and the Truffle extension for VS Code, you can deploy a smart contract using VS Code.