sfi-deployment-sdk
v0.1.1
Published
Reusable ethers v5 helpers for contract deployment scripts and local fork testing.
Maintainers
Readme
SFI Deployment SDK
A small TypeScript module extracted from DynaVaults' deployment-scripts/utils.
It provides reusable ethers v5 helpers for:
- RPC providers, wallets, and gas options
- deployment transaction cost reporting
- Hardhat fork account impersonation and token funding
The module has no DynaVaults contract dependency and contains no private or credentialed RPC URLs.
Requirements
- Node.js 18 or newer
- ethers 5.8
Install
From a sibling project while developing locally:
npm install ../deployment-frameworkOnce the package is published:
npm install sfi-deployment-sdk ethers@^5.8.0Import the complete utility surface directly or as a named namespace:
import * as utils from "sfi-deployment-sdk/utils";
// or
import { utils } from "sfi-deployment-sdk";
const account = utils.getEthersAccount();
const txOptions = await utils.getTxOptions(account.provider!);Configure a deployment
The legacy environment variables are supported, but this package deliberately
does not load .env as an import side effect. Load it in the deployment entry
point if needed (for example, with import "dotenv/config").
RPC_URL=https://your-rpc.example
ACCOUNT_PRIVATE_KEY=0x...
FORKED_CHAIN_ID=8453 # optional; useful when RPC_URL is a local forkConfiguration can also be supplied directly:
import {
configureDeploymentFramework,
getEthersAccount,
getTxOptions,
} from "sfi-deployment-sdk/chain-config";
configureDeploymentFramework({
rpcUrl: process.env.RPC_URL,
privateKey: process.env.ACCOUNT_PRIVATE_KEY,
});
const account = getEthersAccount();
const txOptions = await getTxOptions(account.provider!);getTxOptions uses the configured EIP-1559 strategy for Ethereum and Base. On
other chains it returns a boosted legacy gas price. Override or add a chain
without changing the package:
configureDeploymentFramework({
gasConfigurations: {
10: {
eip1559: true,
percentile: 70,
boostPercent: 10,
gasThresholdGwei: 0.1,
gasRetryMs: 5_000,
},
},
});Report deployment costs
The reporting helpers retain the original function names so existing scripts need only change their import paths.
import { getFastProvider } from "sfi-deployment-sdk/chain-config";
import {
initPhase,
initProvider,
reportCosts,
waitForTx,
} from "sfi-deployment-sdk/chain-utils";
const provider = getFastProvider();
initProvider(provider);
initPhase("Deploy registry");
await waitForTx(await registry.deployTransaction);
await reportCosts();Public, rate-limited reference RPCs and Coinbase spot price endpoints are used for cost comparisons. Production scripts should provide their own endpoints:
import { configureChainUtilities } from "sfi-deployment-sdk/chain-utils";
configureChainUtilities({
mainnetRpcUrls: { 1: process.env.ETHEREUM_REFERENCE_RPC! },
priceEndpoints: { 1: process.env.ETH_USD_PRICE_ENDPOINT! },
});Work with a Hardhat fork
These helpers call Hardhat-only JSON-RPC methods and should never be used against a production RPC.
import {
replenishGas,
transferTokensFromWhale,
} from "sfi-deployment-sdk/testnet-utils";
await replenishGas(provider, deployer.address);
await transferTokensFromWhale(provider, usdc, "1000000", deployer.address, 1);Additional whale mappings can be supplied with configureWhaleWallets.
Unknown chain/token pairs fail before attempting impersonation.
Imports and compatibility
The complete utilities are available from sfi-deployment-sdk/utils. The
focused subpaths are:
sfi-deployment-sdk/chain-configsfi-deployment-sdk/chain-utilssfi-deployment-sdk/testnet-utils
The original underscore paths (chain_config and chain_utils) are also
exported to simplify migration. The root export exposes the three modules as
chainConfig, chainUtils, and testnetUtils; its two conflicting chain ID
helpers are named getProviderChainId and getReportingChainId.
Development
npm install
npm test
npm run format:check
npm pack --dry-run