https://github.com/base/op-viem
Viem extensions for the Op Stack
https://github.com/base/op-viem
Last synced: about 1 year ago
JSON representation
Viem extensions for the Op Stack
- Host: GitHub
- URL: https://github.com/base/op-viem
- Owner: base
- License: mit
- Created: 2023-08-18T18:58:10.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-13T10:11:22.000Z (almost 2 years ago)
- Last Synced: 2025-03-29T10:02:24.378Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://opviem.sh
- Size: 1.06 MB
- Stars: 359
- Watchers: 16
- Forks: 251
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
Viem Extension for OP Stack Chains
## 🚨 DEPRECATION WARNING 🚨
With the upstreaming of most op-viem features into [Viem](https://viem.sh/op-stack) consider this library deprecated. We recommend using [Viem's native OP Stack support](https://viem.sh/op-stack) instead.
## Features
- Simplifies cross L1 & L2 interactions
- Seamless extension to [Viem](https://github.com/wagmi-dev/viem)
- TypeScript ready
- Test suite running against [forked](https://ethereum.org/en/glossary/#fork) Ethereum network
## Overview
```ts
// import modules
import { createWalletClient, createPublicClient, custom, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet, base } from 'viem/chains'
import { baseAddresses } from 'op-viem/chains'
import { walletL1OpStackActions, publicL1OpStackActions, publicL2OpStackActions } from 'op-viem'
// create clients
export const opStackL1WalletClient = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum)
}).extend(walletL1OpStackActions)
export const opStackL1PublicClient = createPublicClient({
chain: mainnet,
transport: http()
}).extend(publicL1OpStackActions)
export const opStackL2PublicClient = createPublicClient({
chain: base,
transport: http()
}).extend(publicL2OpStackActions)
// perform an action
opStackL1PublicClient.getOutputForL2Block(blockNumber: 2725977n, ...baseAddresses)
```
## Community
Check out the following places for more viem-related content:
- Follow [@wilsoncusack](https://twitter.com/wilsoncusack) Twitter for project updates
## Contributing
If you're interested in contributing, please read the [contributing docs](CONTRIBUTING.md) **before submitting a pull request**.
## Authors
- [@wilsoncusack](https://github.com/wilsoncusack) (wilsoncusack.eth [Twitter](https://twitter.com/wilsoncusack))
- [@zencephalon](https://github.com/zencephalon) (zencephalon.eth, [Twitter](https://twitter.com/zencephalon))
- [@roninjin10](https://github.com/roninjin10) (fucory.eth, [Twitter](https://twitter.com/FUCORY))
## License
[MIT](LICENSE.md) License