Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Update example to work cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
Gudahtt committed Mar 27, 2024
1 parent c75b54e commit b9492e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ Web3 ProviderEngine is a tool for composing your own [web3 providers](https://gi
> ```javascript
> import { providerFromMiddleware } from '@metamask/eth-json-rpc-provider';
> import { createFetchMiddleware } from '@metamask/eth-json-rpc-middleware';
> import { valueToBytes, bytesToBase64 } from '@metamask/utils';
> import fetch from 'cross-fetch';
>
> const rpcUrl = '[insert RPC URL here]';
>
> const fetchMiddleware = createFetchMiddleware({ rpcUrl });
> const fetchMiddleware = createFetchMiddleware({
> btoa: (stringToEncode) => bytesToBase64(valueToBytes(stringToEncode)),
> fetch,
> rpcUrl,
> });
> const provider = providerFromMiddleware(fetchMiddleware);
>
> provider.sendAsync(
Expand All @@ -30,7 +36,7 @@ Web3 ProviderEngine is a tool for composing your own [web3 providers](https://gi
> );
> ```
>
> This example was written with v12.1.0 of `@metamask/eth-json-rpc-middleware` and v3.0.1 of `@metamask/eth-json-rpc-provider`.
> This example was written with v12.1.0 of `@metamask/eth-json-rpc-middleware`, v3.0.1 of `@metamask/eth-json-rpc-provider`, and v8.4.0 of `@metamask/utils`.
>
Expand Down

0 comments on commit b9492e7

Please sign in to comment.