Skip to content

Commit

Permalink
Support HTTP or WebSocket connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
telackey committed Apr 24, 2024
1 parent cbe477e commit e12d826
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/nitro-util/src/eth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export class EthClient {

static dial(chainUrl: string): EthClient {
// Connect to the Ethereum provider
const provider = new ethers.providers.WebSocketProvider(chainUrl);
let provider;
if (chainUrl.startsWith('ws://') || chainUrl.startsWith('wss://')) {
provider = new ethers.providers.WebSocketProvider(chainUrl);
} else {
provider = new ethers.providers.JsonRpcProvider(chainUrl);
}
return new EthClient(provider);
}

Expand Down

0 comments on commit e12d826

Please sign in to comment.