Skip to content

Commit

Permalink
feat(zksync): add zksync local hyperchain networks (#3081)
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion authored Dec 2, 2024
1 parent acc496a commit 0d9dfcd
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/eighty-wolves-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": minor
---

Added `ZKsync` local hyperchain networks
25 changes: 25 additions & 0 deletions src/chains/definitions/zksyncLocalCustomHyperchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineChain } from '../../utils/chain/defineChain.js'
import { chainConfig } from '../../zksync/chainConfig.js'

// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml

export const zksyncLocalCustomHyperchain = /*#__PURE__*/ defineChain({
...chainConfig,
id: 272,
name: 'ZKsync CLI Local Custom Hyperchain',
nativeCurrency: { name: 'BAT', symbol: 'BAT', decimals: 18 },
rpcUrls: {
default: {
http: ['http://localhost:15200'],
webSocket: ['ws://localhost:15201'],
},
},
blockExplorers: {
default: {
name: 'ZKsync explorer',
url: 'http://localhost:15005/',
apiUrl: 'http://localhost:15005/api',
},
},
testnet: true,
})
25 changes: 25 additions & 0 deletions src/chains/definitions/zksyncLocalHyperchain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineChain } from '../../utils/chain/defineChain.js'
import { chainConfig } from '../../zksync/chainConfig.js'

// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml

export const zksyncLocalHyperchain = /*#__PURE__*/ defineChain({
...chainConfig,
id: 270,
name: 'ZKsync CLI Local Hyperchain',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['http://localhost:15100'],
webSocket: ['ws://localhost:15101'],
},
},
blockExplorers: {
default: {
name: 'ZKsync explorer',
url: 'http://localhost:15005/',
apiUrl: 'http://localhost:15005/api',
},
},
testnet: true,
})
22 changes: 22 additions & 0 deletions src/chains/definitions/zksyncLocalHyperchainL1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { defineChain } from '../../utils/chain/defineChain.js'

// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml

export const zksyncLocalHyperchainL1 = /*#__PURE__*/ defineChain({
id: 9,
name: 'ZKsync CLI Local Hyperchain L1',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['http://localhost:15045'],
},
},
blockExplorers: {
default: {
name: 'Blockscout',
url: 'http://localhost:15001/',
apiUrl: 'http://localhost:15001/api/v2',
},
},
testnet: true,
})
3 changes: 3 additions & 0 deletions src/chains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ export {
zksyncInMemoryNode as zkSyncInMemoryNode,
zksyncInMemoryNode,
} from './definitions/zksyncInMemoryNode.js'
export { zksyncLocalCustomHyperchain } from './definitions/zksyncLocalCustomHyperchain.js'
export { zksyncLocalHyperchain } from './definitions/zksyncLocalHyperchain.js'
export { zksyncLocalHyperchainL1 } from './definitions/zksyncLocalHyperchainL1.js'
export {
/** @deprecated Use `zksync` instead */
zksyncLocalNode as zkSyncLocalNode,
Expand Down
3 changes: 3 additions & 0 deletions src/zksync/chains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint module
export { zksync } from '../chains/definitions/zksync.js'
export { zksyncInMemoryNode } from '../chains/definitions/zksyncInMemoryNode.js'
export { zksyncLocalCustomHyperchain } from '../chains/definitions/zksyncLocalCustomHyperchain.js'
export { zksyncLocalHyperchain } from '../chains/definitions/zksyncLocalHyperchain.js'
export { zksyncLocalHyperchainL1 } from '../chains/definitions/zksyncLocalHyperchainL1.js'
export { zksyncLocalNode } from '../chains/definitions/zksyncLocalNode.js'
export { zksyncSepoliaTestnet } from '../chains/definitions/zksyncSepoliaTestnet.js'
3 changes: 3 additions & 0 deletions src/zksync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export {
zksync,
/** @deprecated Use `zksync` instead */
zksyncInMemoryNode as zkSyncInMemoryNode,
zksyncLocalCustomHyperchain,
zksyncLocalHyperchain,
zksyncLocalHyperchainL1,
zksyncInMemoryNode,
/** @deprecated Use `zksync` instead */
zksyncLocalNode as zkSyncLocalNode,
Expand Down

0 comments on commit 0d9dfcd

Please sign in to comment.