ts-abigen

Generate nodejs modules from ethereum smart contracts

Usage no npm install needed!

<script type="module">
  import tsAbigen from 'https://cdn.skypack.dev/ts-abigen';
</script>

README

  • ts-abigen - Convert solc contract output to typescript interfaces

** Usage First compile your contract

+begin_src shell

solc --combined-json=abi,bin --optimize contract.sol > combined.json

+end_src

Then convert contracts to typescript

+begin_src shell

./bin/ts-abigen.js --out ./local_modules/test-contract --name test-contract --combined combined.json

+end_src

Using your contract(s)

+begin_src typescript

// Change this to match your contract import { contracts } from './local_modules/test-contract'

const contract = new ExampleContract( 'http://localhost:8545', '0x48624beaad14ea386e2185839aa10c1faf6b973a', {}) //

Promise.resolve() .then(async () => { const z = '0x0000000000000000000000000000000000000000000000000000000000000000' const result = await contract.sanityCheck.call(z, z) console.log(result) }) .then(_ => { process.exit(0) }) .catch(err => { console.error(err) process.exit(1) })

+end_src