chainsmith
v0.1.0
Published
A lightweight TypeScript library for deploying and tracking smart contract deployments across EVM networks.
Downloads
173
Maintainers
Readme
chainsmith
A lightweight TypeScript library for deploying and tracking smart contract deployments across EVM networks, built on ethers.js v6.
Why
Deploying the same contract to multiple networks (or redeploying during development) usually means hand-rolling the same boilerplate: retry on flaky RPC/gas errors, wait for confirmations, and remember which address you deployed to on which chain. chainsmith handles that in one call and writes a JSON deployment record you can commit or inspect later.
Install
npm install chainsmith ethersUsage
import { ContractDeployer } from "chainsmith";
import { JsonRpcProvider, Wallet } from "ethers";
import artifact from "./artifacts/MyToken.json";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const signer = new Wallet(process.env.PRIVATE_KEY!, provider);
const deployer = new ContractDeployer(signer, "deployments");
const record = await deployer.deploy(
"MyToken",
artifact.abi,
artifact.bytecode,
["My Token", "MTK"],
{ confirmations: 2, skipIfDeployed: true }
);
console.log(`Deployed MyToken to ${record.address} (tx ${record.txHash})`);Deployment records are written to <deploymentsDir>/<chainId>/<name>.json, e.g. deployments/11155111/MyToken.json, so you can check them into version control and diff deployments across environments.
API
new ContractDeployer(signer, deploymentsDir = "deployments")
signer— anethers.Signerconnected to a provider.deploymentsDir— directory where deployment records are read/written.
deployer.deploy(name, abi, bytecode, args?, options?)
Deploys a contract and returns a DeploymentRecord. Retries on transient errors with linear backoff.
| Option | Default | Description |
| --- | --- | --- |
| confirmations | 1 | Blocks to wait for before returning. |
| skipIfDeployed | false | If a record already exists for this name + chain ID, return it instead of redeploying. |
| retries | 3 | Attempts before giving up. |
| retryDelayMs | 1500 | Base delay between retries (multiplied by attempt number). |
| overrides | {} | Passed through to ContractFactory.deploy (e.g. gasLimit, value). |
deployer.getDeployment(name)
Returns the saved DeploymentRecord for name on the signer's current network, or null.
Development
npm install
npm run build
npm test