Skip to content

enumatech/ts-abigen

Repository files navigation

ts-abigen - Convert solc contract output to typescript interfaces

Usage

First compile your contract

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

Then convert contracts to typescript

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

Using your contract(s)

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