Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more
logo

solc

nest badge

⚠️ Highly experimental!

Solidity v0.8.7 bindings for Deno, based on solc-js.

Docs

See solc-js README.

Example

import { setupSolc } from 'https://deno.land/x/solc/mod.ts'
import { download } from 'https://deno.land/x/solc/download.ts'

await download('./soljson.js') // download soljson

const solc = setupSolc('./soljson.js') // require(...) soljson to Deno

const input = {
  sources: {
    'test.sol': {
      content: 'contract C { function f() public { } }'
    }
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*']
      }
    }
  }
}

const { contracts } = JSON.parse(solc.compile(JSON.stringify(input)))

// `output` here contains the JSON output as specified in the documentation
for (const contractName in contracts['test.sol']) {
  console.log(`${contractName}: ${contracts['test.sol'][contractName].evm.bytecode.object}`)
}

And then run with

deno run -A --unstable --no-check mod.js