Skip to content

deno-web3/solc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

solc

nest badge GitHub Workflow Status Codecov

Solidity bindings for Deno, based on solc-js.

Solidity 0.7+ is supported.

For a CLI and a higher level API you can use sol_build.

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 'node:module'

// 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