Custom RPC endpoint for calls
Is there a way to configure calls to route to a custom endpoint, for example, the Cartridge powered node: https://twitter.com/cartridge_gg/status/1524391388841975808.
As a follow-up - is there a way to specify a cascading set of endpoints => if one fails to respond, the other will be used as a back-up.
It's possible if you have a version of starknet.js that supports rpc providers. Just specify the rpc provider as defaultProvider.
<StarknetProvider defaultProvider={new RpcProvider(...)}>
...
</StarknetProvider>
As for the second question, it should be an option in starknet.js I think.
Hi! Not sure if I should create a separate issue. I have provided a defaultProvider.
<StarknetConfig defaultProvider={provider} connectors={connectors}>
...
</StarknetProvider>
Where provider is testnet-2:
new Provider({
sequencer: {
baseUrl: "https://alpha4-2.starknet.io",
feederGatewayUrl:"https://alpha4-2.starknet.io/feeder_gateway",
gatewayUrl: "https://alpha4.starknet.io/gateway"
}
})
It's working well when the page is loaded. When I connect a wallet, the provider is updated with the provider of the wallet which is fine. But when I disconnect my wallet the defaultProvider is back to testnet-1 where it should be back to testnet-2.
This looks like a bug @schwepps! The culprit is this line where the provider should be set to the default provider.
Thanks @fracek. Do you want me to open a PR with the fix?
Yes please! I don't have the time to write a fix but happy to review a pr.
I encounter the same issue. When using mainnet, after disconnecting we're back to testnet, which leads to really flaky UI...
@gabsn I opened a PR to fix it: #199
Fixed in #199.