Skip to content

Commit

Permalink
docs: rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 6, 2024
1 parent dcb2236 commit afb2483
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion site/react/guides/read-from-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ReadContract() {
```
:::

If `useReadContract` depends on another value (`address` in the example below), you can use the [`query.enabled`](http://localhost:5173/react/api/hooks/useReadContract#enabled) option to prevent the query from running until the dependency is ready.
If `useReadContract` depends on another value (`address` in the example below), you can use the [`query.enabled`](/react/api/hooks/useReadContract#enabled) option to prevent the query from running until the dependency is ready.

```tsx
const { data: balance } = useReadContract({
Expand Down
2 changes: 1 addition & 1 deletion site/shared/transports/fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const config = createConfig({
connectors: [injected()],
transports: {
[mainnet.id]: fallback([ // [!code hl]
http('https://eth-mainnet.g.alchemy.com/v2/...'), // [!code hl]
http('https://foo-bar-baz.quiknode.pro/...'), // [!code hl]
http('https://mainnet.infura.io/v3/...'), // [!code hl]
]) // [!code hl]
},
Expand Down
28 changes: 14 additions & 14 deletions site/shared/transports/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [injected()],
transports: {
[mainnet.id]: http('https://eth-mainnet.g.alchemy.com/v2/...'), // [!code hl]
[sepolia.id]: http('https://eth-sepolia.g.alchemy.com/v2/...'), // [!code hl]
[mainnet.id]: http('https://foo-bar-baz.quiknode.pro/...'), // [!code hl]
[sepolia.id]: http('https://foo-bar-sep.quiknode.pro/...'), // [!code hl]
},
})
```
Expand All @@ -44,7 +44,7 @@ The Transport will batch up Actions over a given period and execute them in a si
You can enable Batch JSON-RPC by setting the `batch` flag to `true`:

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
batch: true // [!code hl]
})
```
Expand All @@ -58,7 +58,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
URL of the JSON-RPC API. Defaults to `chain.rpcUrls.default.http[0]`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...')
const transport = http('https://foo-bar-baz.quiknode.pro/...')
```

### batch
Expand All @@ -68,7 +68,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...')
Toggle to enable Batch JSON-RPC. Defaults to `false`

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
batch: true // [!code focus]
})
```
Expand All @@ -80,7 +80,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
The maximum number of JSON-RPC requests to send in a batch. Defaults to `1_000`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
batch: {
batchSize: 2_000 // [!code focus]
}
Expand All @@ -94,7 +94,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
The maximum number of milliseconds to wait before sending a batch. Defaults to `0` ([zero delay](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Event_loop#zero_delays)).

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
batch: {
wait: 16 // [!code focus]
}
Expand All @@ -108,7 +108,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
[Fetch options](https://developer.mozilla.org/en-US/docs/Web/API/fetch) to pass to the internal `fetch` function. Useful for passing auth headers or cache options.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
fetchOptions: { // [!code focus:5]
headers: {
'Authorization': 'Bearer ...'
Expand All @@ -124,7 +124,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
A key for the Transport. Defaults to `"http"`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
key: 'alchemy', // [!code focus]
})
```
Expand All @@ -136,7 +136,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
A name for the Transport. Defaults to `"HTTP JSON-RPC"`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
name: 'Alchemy HTTP Provider', // [!code focus]
})
```
Expand All @@ -148,7 +148,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
The max number of times to retry when a request fails. Defaults to `3`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
retryCount: 5, // [!code focus]
})
```
Expand All @@ -160,7 +160,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
The base delay (in ms) between retries. By default, the Transport will use [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) (`~~(1 << count) * retryDelay`), which means the time between retries is not constant.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
retryDelay: 100, // [!code focus]
})
```
Expand All @@ -172,7 +172,7 @@ const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
The timeout for requests. Defaults to `10_000`.

```ts
const transport = http('https://eth-mainnet.g.alchemy.com/v2/...', {
const transport = http('https://foo-bar-baz.quiknode.pro/...', {
timeout: 60_000, // [!code focus]
})
```
```
2 changes: 1 addition & 1 deletion site/shared/transports/unstable_connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const config = createConfig({
transports: {
[mainnet.id]: fallback([
unstable_connector(injected), // [!code hl]
http('https://eth-mainnet.g.alchemy.com/v2/...')
http('https://foo-bar-baz.quiknode.pro/...')
])
},
})
Expand Down
18 changes: 9 additions & 9 deletions site/shared/transports/webSocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const config = createConfig({
chains: [mainnet, sepolia],
connectors: [injected()],
transports: {
[mainnet.id]: webSocket('wss://eth-mainnet.g.alchemy.com/v2/...'), // [!code hl]
[sepolia.id]: webSocket('wss://eth-sepolia.g.alchemy.com/v2/...'), // [!code hl]
[mainnet.id]: webSocket('wss://foo-bar-baz.quiknode.pro/...'), // [!code hl]
[sepolia.id]: webSocket('wss://foo-bar-sep.quicknode.pro/...'), // [!code hl]
},
})
```
Expand All @@ -44,7 +44,7 @@ If no URL is provided, then the transport will fall back to a public RPC URL on
URL of the JSON-RPC API.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...')
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...')
```

### key (optional)
Expand All @@ -54,7 +54,7 @@ const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...')
A key for the Transport. Defaults to `"webSocket"`.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...', {
key: 'alchemy', // [!code focus]
})
```
Expand All @@ -66,7 +66,7 @@ const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
A name for the Transport. Defaults to `"WebSocket JSON-RPC"`.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...', {
name: 'Alchemy WebSocket Provider', // [!code focus]
})
```
Expand All @@ -78,7 +78,7 @@ const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
The max number of times to retry when a request fails. Defaults to `3`.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...', {
retryCount: 5, // [!code focus]
})
```
Expand All @@ -90,7 +90,7 @@ const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
The base delay (in ms) between retries. By default, the Transport will use [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) (`~~(1 << count) * retryDelay`), which means the time between retries is not constant.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...', {
retryDelay: 100, // [!code focus]
})
```
Expand All @@ -102,7 +102,7 @@ const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
The timeout for async WebSocket requests. Defaults to `10_000`.

```ts
const transport = webSocket('wss://eth-mainnet.g.alchemy.com/v2/...', {
const transport = webSocket('wss://foo-bar-baz.quiknode.pro/...', {
timeout: 60_000, // [!code focus]
})
```
```
2 changes: 1 addition & 1 deletion site/vue/guides/read-from-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const { data: balance } = useReadContract({
:::


If `useReadContract` depends on another value (`address` in the example below), you can use the [`query.enabled`](http://localhost:5173/vue/api/composables/useReadContract#enabled) option to prevent the query from running until the dependency is ready.
If `useReadContract` depends on another value (`address` in the example below), you can use the [`query.enabled`](/vue/api/composables/useReadContract#enabled) option to prevent the query from running until the dependency is ready.

```tsx
const { data: balance } = useReadContract({
Expand Down

0 comments on commit afb2483

Please sign in to comment.