Skip to content

Commit

Permalink
Add Viem documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aefhm committed Nov 17, 2023
1 parent e7897fc commit 5bb22f0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions clients/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,44 @@ const provider = sapphire.wrap(window.ethereum);
window.ethereum = sapphire.wrap(window.ethereum); // If you're feeling bold.
```

### Viem

```ts
import * as sapphire from '@oasisprotocol/sapphire-paratime';

const sapphireChainTestnet: Chain = {
id: sapphire.NETWORKS.testnet.chainId,
name: 'Sapphire',
network: 'sapphire',
nativeCurrency: {
decimals: 18,
name: 'Sapphire',
symbol: 'ROSE',
},
rpcUrls: {
default: {
http: [sapphire.NETWORKS.testnet.defaultGateway],
},
public: {
http: [sapphire.NETWORKS.testnet.defaultGateway],
},
},
blockExplorers: {
default: {
name: 'Sapphire Explorer (Testnet)',
url: sapphire.NETWORKS.testnet.defaultGateway
},
},
testnet: true,
};

const provider = sapphire.wrap(window.ethereum! as EIP1193Provider);
const walletClient = createWalletClient({
chain: sapphireChainTestnet,
transport: custom(provider),
});
```

## Troubleshooting

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

0 comments on commit 5bb22f0

Please sign in to comment.