Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solc

Package Overview
Dependencies
Maintainers
3
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solc

Solidity compiler

  • 0.8.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
179K
decreased by-55.74%
Maintainers
3
Weekly downloads
 
Created

What is solc?

The solc npm package is a JavaScript binding for the Solidity compiler. It allows developers to compile Solidity code from within a JavaScript environment, making it easier to integrate smart contract compilation into web applications, development tools, and automated scripts.

What are solc's main functionalities?

Compile Solidity Source Code

This feature allows you to compile Solidity source code. The code sample demonstrates how to compile a simple Solidity contract using the solc package.

const solc = require('solc');
const source = 'contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } function get() public view returns (uint) { return storedData; } }';
const input = {
  language: 'Solidity',
  sources: {
    'SimpleStorage.sol': {
      content: source
    }
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*']
      }
    }
  }
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
console.log(output);

Get Compiler Version

This feature allows you to retrieve the version of the Solidity compiler being used. The code sample demonstrates how to get the compiler version using the solc package.

const solc = require('solc');
console.log(solc.version());

Compile with Specific Compiler Version

This feature allows you to compile Solidity code using a specific version of the Solidity compiler. The code sample demonstrates how to compile a contract using a specific compiler version.

const solc = require('solc');
const solcVersion = 'v0.8.6+commit.11564f7e';
const solcjs = require(`solc/soljson-${solcVersion}.js`);
const input = {
  language: 'Solidity',
  sources: {
    'SimpleStorage.sol': {
      content: 'contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } function get() public view returns (uint) { return storedData; } }'
    }
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*']
      }
    }
  }
};
const output = JSON.parse(solcjs.compile(JSON.stringify(input)));
console.log(output);

Other packages similar to solc

Keywords

FAQs

Package last updated on 16 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc