cds-amal / solc

πŸ’Ž Solidity compiler bindings for Deno

Home Page:https://nest.land/package/solc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

logo

solc

nest badge GitHub Workflow Status Codecov

Solidity bindings for Deno, based on solc-js.

Solidity 0.7+ is supported.

Docs

See solc-js README and Deno doc.

Example

import { wrapper } from 'https://deno.land/x/solc/mod.ts'
import { Input } from 'https://deno.land/x/solc/types.ts'
import { download } from 'https://deno.land/x/solc/download.ts'
import { createRequire } from 'https://deno.land/std@0.177.0/node/module.ts'

// Download latest Solidity compiler
await download()

const solc = wrapper(createRequire(import.meta.url)('./soljson.js'))

const MyToken = await Deno.readTextFile('./MyToken.sol')
const ERC20 = await Deno.readTextFile('./ERC20.sol')

const input: Input = {
  language: 'Solidity',
  sources: {
    'MyToken.sol': {
      content: MyToken,
    },
    'ERC20.sol': {
      content: ERC20,
    },
  },
  settings: {
    outputSelection: {
      '*': {
        '*': ['*'],
      },
    },
  },
}
console.log(JSON.parse(solc.compile(JSON.stringify(input))))

And then run with

deno run -allow-net --allow-read --allow-write mod.ts

About

πŸ’Ž Solidity compiler bindings for Deno

https://nest.land/package/solc

License:MIT License


Languages

Language:TypeScript 100.0%