---
tags: v3, contracts
---
# Typechain Sync (5/25/22)
- Govrn example: Scoped to a single contract
- Codegen comes from this
- Instantiates a factory in the SDK
- Typechain generated the types and also passes the ABI into the contract instance
- Try to set this up with the Baal Summmoner App with a function to summon a Baal
- Need to review and merge in #199 since this has a new app in the repo
## Baal Summoner Function (Baal Factory)
- Generate the typechain and the ethers pieces and wrap in a contract specific SDK and then wrap this in the dao-data SDK for the more complex data functions
- Can then allow for other applications to use only the contract SDK if needed
- One package for entire protocol
### Steps
- Make new `lib` with `nx`
- `nx g @nrwl/js:lib <lib_name> --importPath @daohaus/<package_name> --publishable true`
- Such as `baal-contract-sdk`
- Need the JSON ABIs
- Specify JSON files in this path
- Install typechain and make sure you have all the ABIs
- Need the ethers specific one
- Run the `typechain` command with `--target ethers-v5` and the paths (output and ABIs)
- `nx run baal-contract-sdk:typechain`
- Generates an type `interface` from the command and the ABI and the function definitions
- There is a `connect` function that returns a ethers contract with the address and the ABI set up already -- need the provider
- Using:
- Have a client within the `lib` -- doesn't export the generated factories
- Instead a client wraps the factory and explicitly exposes the methods
-