Skip to content

Commit

Permalink
Use viem 2.7.11 for l1StandardBridge support, update docs to reflect
Browse files Browse the repository at this point in the history
  • Loading branch information
zencephalon committed Feb 20, 2024
1 parent b83eeed commit 69f0c58
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 67 deletions.
88 changes: 44 additions & 44 deletions docs/docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,63 @@
## Configuration

OP Wagmi currently ships with support for Base, Base Goerli, Optimism, Optimism Goerli, Zora, and Zora Goerli. If you'd like to interact with other OP Stack chains, you can extend Wagmi's config to include a list of additional `l2Chains`. You'll also need to add the corresponding chain objects to your Wagmi config so OP Wagmi has access to RPC URLs etc.
OP Wagmi works out of the box with any OP Stack Viem chain definition as of Viem 2.7.11. You'll just need to add the corresponding chain objects to your Wagmi config as normal. You can also specify custom chains and pass them to Wagmi's config.

::: code-group

```tsx [app.tsx]
import { useWriteDepositETH } from 'op-wagmi'
import { useConfig } from 'wagmi'
import { customL2Chains } from './l2Chains'

const { writeDepositETH } = useWriteDepositETH()

return (
<button
onClick={() => (writeDepositETH({
args: {
to: '0x968Bb4fF2482ff56Af1255019d5b955510A1159e',
amount: 1n,
},
l2ChainId: 1230123,
}))}
>
Deposit ETH
</button>
)
```

```ts [config.ts]
import { createConfig, http } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { exampleChain } from './chains'

export const config = createConfig({
chains: [mainnet, sepolia, exampleChain],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
[exampleChain.id]: http(),
},
})
```

```ts [l2Chains.ts]
import { type Chain, mainnet } from 'viem/chains'

export const exampleChain: Chain = {
id: 8453,
name: 'Base',
id: 31415926,
name: 'ExampleChain',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['https://mainnet.base.org'],
http: ['https://rpc.examplechain.org'],
},
},
blockExplorers: {
default: {
name: 'Basescan',
url: 'https://basescan.org',
apiUrl: 'https://api.basescan.org/api',
name: 'ExampleChain Scan',
url: 'https://examplechainscan.org',
apiUrl: 'https://api.examplechainscan.org/api',
},
},
contracts: {
Expand Down Expand Up @@ -49,41 +86,4 @@ export const exampleChain: Chain = {
}
```

```tsx [app.tsx]
import { useWriteDepositETH } from 'op-wagmi'
import { useConfig } from 'wagmi'
import { customL2Chains } from './l2Chains'

const { writeDepositETH } = useWriteDepositETH()

return (
<button
onClick={() => (writeDepositETH({
args: {
to: '0x968Bb4fF2482ff56Af1255019d5b955510A1159e',
amount: 1n,
},
l2ChainId: 1230123,
}))}
>
Deposit ETH
</button>
)
```

```ts [config.ts]
import { createConfig, http } from 'wagmi'
import { mainnet, sepolia } from 'wagmi/chains'
import { exampleChain } from './chains'

export const config = createConfig({
chains: [mainnet, sepolia, exampleChain],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
[exampleChain.id]: http(),
},
})
```

:::
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"@wagmi/core": "^2.x",
"op-viem": "1.3.1-alpha",
"typescript": ">=5.0.4",
"viem": "^2.x",
"viem": "^2.7.11",
"wagmi": "^2.x"
},
"peerDependenciesMeta": {
Expand Down
44 changes: 22 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 69f0c58

Please sign in to comment.