Skip to content

Commit 12a1ba2

Browse files
committed
Add Viem documentation
1 parent e7897fc commit 12a1ba2

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

clients/js/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,44 @@ const provider = sapphire.wrap(window.ethereum);
6868
window.ethereum = sapphire.wrap(window.ethereum); // If you're feeling bold.
6969
```
7070

71+
### Viem
72+
73+
```ts
74+
import * as sapphire from '@oasisprotocol/sapphire-paratime';
75+
76+
const sapphireChainTestnet: Chain = {
77+
id: sapphire.NETWORKS.testnet.chainId,
78+
name: 'Sapphire',
79+
network: 'sapphire',
80+
nativeCurrency: {
81+
decimals: 18,
82+
name: 'Sapphire',
83+
symbol: 'ROSE',
84+
},
85+
rpcUrls: {
86+
default: {
87+
http: [sapphire.NETWORKS.testnet.defaultGateway],
88+
},
89+
public: {
90+
http: [sapphire.NETWORKS.testnet.defaultGateway],
91+
},
92+
},
93+
blockExplorers: {
94+
default: {
95+
name: 'Sapphire Explorer (Testnet)',
96+
url: sapphire.NETWORKS.testnet.defaultGateway,
97+
},
98+
},
99+
testnet: true,
100+
};
101+
102+
const provider = sapphire.wrap(window.ethereum! as EIP1193Provider);
103+
const walletClient = createWalletClient({
104+
chain: sapphireChainTestnet,
105+
transport: custom(provider),
106+
});
107+
```
108+
71109
## Troubleshooting
72110

73111
### `Error: missing provider (operation="getChainId", code=UNSUPPORTED_OPERATION, ...)`

0 commit comments

Comments
 (0)