The portal currently uses ethers v6 across ~50 files, connected to wagmi/viem through a translation layer (ethers.ts) that converts viem wallet clients back into ethers signers. This is a round-trip through two libraries for the same JSON-RPC provider — adds ~120 KB to the bundle and blocks EIP-5792.
This ticket removes ethers entirely and moves everything to viem.
Scope
~50 files across three areas:
Utilities (~25 instances, low risk). Most have 1:1 viem equivalents: parseUnits, formatUnits, getAddress, keccak256, toHex, isHex, hexToNumber, hexToBigInt, encodePacked. Affected files: units.ts, helper.ts, chain.ts, chain_id.ts, miner.ts, delegations.ts.
@skalenetwork/skale-contracts-ethers-v6 → @skalenetwork/skale-contracts-viem (5 files, medium risk). The viem adapter exists (2.0.0-develop.7, released March 2026). Same API shape, different underlying types. Used in: contracts/index.ts, contracts/baseChain.ts, contracts/paymaster.ts, metaport.ts, credit-station.ts. Risk: pre-release package — if it has gaps, keep ethers for this one dependency and file upstream issues.
Contract and transaction layer (~20 files, bulk of the work). Refactor BaseChain/SChain/MainnetChain classes: provider: Provider → publicClient: PublicClient, signer: Signer → walletClient: WalletClient. All new Contract(addr, abi, signer) → getContract({ address, abi, client }). All .connect(signer) calls go away. Rewrite transactions.ts from signer.sendTransaction() to walletClient.writeContract() + publicClient.waitForTransactionReceipt(). Update error handling (ethers ACTION_REJECTED → viem UserRejectedRequestError). Update MetaportState.ts and all components using useEthersSigner()/useEthersProvider() to use wagmi hooks directly.
Final cleanup. Delete ethers.ts translation layer. Remove ethers from all package.json files.
The portal currently uses ethers v6 across ~50 files, connected to wagmi/viem through a translation layer (
ethers.ts) that converts viem wallet clients back into ethers signers. This is a round-trip through two libraries for the same JSON-RPC provider — adds ~120 KB to the bundle and blocks EIP-5792.This ticket removes ethers entirely and moves everything to viem.
Scope
~50 files across three areas:
Utilities (~25 instances, low risk). Most have 1:1 viem equivalents:
parseUnits,formatUnits,getAddress,keccak256,toHex,isHex,hexToNumber,hexToBigInt,encodePacked. Affected files:units.ts,helper.ts,chain.ts,chain_id.ts,miner.ts,delegations.ts.@skalenetwork/skale-contracts-ethers-v6→@skalenetwork/skale-contracts-viem(5 files, medium risk). The viem adapter exists (2.0.0-develop.7, released March 2026). Same API shape, different underlying types. Used in:contracts/index.ts,contracts/baseChain.ts,contracts/paymaster.ts,metaport.ts,credit-station.ts. Risk: pre-release package — if it has gaps, keep ethers for this one dependency and file upstream issues.Contract and transaction layer (~20 files, bulk of the work). Refactor
BaseChain/SChain/MainnetChainclasses:provider: Provider→publicClient: PublicClient,signer: Signer→walletClient: WalletClient. Allnew Contract(addr, abi, signer)→getContract({ address, abi, client }). All.connect(signer)calls go away. Rewritetransactions.tsfromsigner.sendTransaction()towalletClient.writeContract()+publicClient.waitForTransactionReceipt(). Update error handling (ethersACTION_REJECTED→ viemUserRejectedRequestError). UpdateMetaportState.tsand all components usinguseEthersSigner()/useEthersProvider()to use wagmi hooks directly.Final cleanup. Delete
ethers.tstranslation layer. Removeethersfrom allpackage.jsonfiles.