/new-contract
Scaffold a new Solidity contract following the project's existing patterns.
Instructions
Ask the user for:
- Contract name (PascalCase, e.g.,
MyToken) - Token standard (ERC20, ERC721, ERC1155, or custom)
- Features needed (Ownable, Pausable, Burnable, etc.)
- Contract name (PascalCase, e.g.,
Create the contract in
contracts/<ContractName>.sol:- Use
pragma solidity 0.8.28; - Import from
@openzeppelin/contracts/ - Follow the patterns in existing contracts (e.g.,
BasicERC20.sol) - Pass
initialOwnertoOwnableconstructor (OpenZeppelin v5 pattern) - Include SPDX-License-Identifier: MIT
- Use
Create the test file in
test/<ContractName>.ts:- Use the
setupFixture+loadFixturepattern from existing tests - Use top-level
await hre.network.connect()for ethers/networkHelpers - Test constructor parameters, core functionality, and access control
- Use
revertedWithCustomErrorfor OpenZeppelin error assertions
- Use the
Create the Ignition module in
ignition/modules/<ContractName>Module.ts:- Follow
buildModulepattern from existing modules - Use
m.getParameter()with sensible defaults - Use
m.getAccount(0)for owner/deployer - Export as default
- Follow
Create task files in
tasks/<token-type>/:- Use Hardhat v3 task API:
task().addOption().setInlineAction().build() - Include usage example in comment
- Export named const
- Use Hardhat v3 task API:
Register tasks in
hardhat.config.ts:- Import the new task(s)
- Add to the
tasksarray
Verify everything works:
- Run
npm run compileto verify the contract compiles - Run
npm run testto verify tests pass - Run
npm run sol:format:writeto format the Solidity file - Run
npm run format:writeto format TypeScript files
- Run
Source: protokol/solidity-typescript-hardhat-template — distributed by TomeVault.