Attributes
Includes Deno configuration
Repository
Current version released
2 years ago
Dependencies
esm.sh
std
Solidity bindings for Deno, based on solc-js.
Solidity 0.7+ is supported.
Docs
See solc-js README and Deno doc.
Example
import { setupSolc } 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'
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 solc = setupSolc('./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