File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ const provider = sapphire.wrap(window.ethereum);
6868window .ethereum = sapphire .wrap (window .ethereum ); // If you're feeling bold.
6969```
7070
71+ ### Viem
72+
73+ ``` ts
74+ import { sapphireTestnet } from ' viem/chains' ;
75+ import * as sapphire from ' @oasisprotocol/sapphire-paratime' ;
76+
77+ const provider = sapphire .wrap (window .ethereum ! as EIP1193Provider );
78+ const walletClient = createWalletClient ({
79+ chain: sapphireTestnet ,
80+ transport: custom (provider ),
81+ });
82+ ```
83+
7184## Troubleshooting
7285
7386### ` Error: missing provider (operation="getChainId", code=UNSUPPORTED_OPERATION, ...) `
Original file line number Diff line number Diff line change @@ -125,6 +125,25 @@ can also use those with Sapphire; all you need to do is set your Web3 gateway UR
125125You can find the details of the Oasis Sapphire Web3 gateway
126126[ here] ( /dapp/sapphire#web3-gateway ) .
127127
128+ #### Viem
129+
130+ Sapphire will mostly work with Viem out of the box. You will need to import
131+ the Sapphire client, define the ` chain ` , and wrap your ` provider ` before
132+ creating a [ custom] transport.
133+
134+ [ custom ] : https://viem.sh/docs/clients/transports/custom.html
135+
136+ ``` ts
137+ import { sapphireTestnet } from ' viem/chains' ;
138+ import * as sapphire from ' @oasisprotocol/sapphire-paratime' ;
139+
140+ const provider = sapphire .wrap (window .ethereum ! as EIP1193Provider );
141+ const walletClient = createWalletClient ({
142+ chain: sapphireTestnet ,
143+ transport: custom (provider ),
144+ });
145+ ```
146+
128147### Transactions & Calls
129148
130149<!-- https://github.com/oasisprotocol/docs/blob/455980674563cad92ff1e1b62a7a5f2d4d6809f0/docs/general/images/architecture/client-km-compute.svg -->
You can’t perform that action at this time.
0 commit comments