Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
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'
const exists = async (filename: string): Promise<boolean> => {
try {
await Deno.stat(filename)
return true
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
return false
} else {
throw error
}
}
}
if (!(await exists('./soljson.js'))) await download('./soljson.js')
const dec = new TextDecoder()
const require = createRequire(import.meta.url)
const solc = wrapper(require('./soljson.js'))
const readFile = async (path: string) => {
const file = await Deno.readFile(path)
return dec.decode(file)
}
const MyToken = await readFile('./MyToken.sol')
const ERC20 = await readFile('./ERC20.sol')
const input: Input = {
language: 'Solidity',
sources: {
'MyToken.sol': {
content: MyToken
},
'ERC20.sol': {
content: ERC20
}
},
settings: {
outputSelection: {
'*': {
'*': ['*']
}
}
}
}
const result = JSON.parse(solc.compile(JSON.stringify(input)))
console.log(result)
And then run with
deno run -allow-net --allow-read --allow-write mod.ts