Skip to content

Commit

Permalink
feat: added public addresses with failover (#365)
Browse files Browse the repository at this point in the history
* feat: added public addresses with failover

* Update

* fix: revert to lilypad RPC endpoint

* fix: removed quicknode rpc in favor of alchemy

* Chore: remove comment

Thanks @narbs91 I removed the commented code

* 5 public wss rpc update

---------

Co-authored-by: Arsen Yeremin <[email protected]>
  • Loading branch information
noryev and arsen3d authored Sep 17, 2024
1 parent 0336c2c commit 973f396
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/options/configs/testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mediator = ["0x7B49d6ee530B0A538D26E344f3B02E79ACa96De2"]
api_host = "https://api-testnet.lilypad.tech/"

[web3]
rpc_url = "wss://capable-tame-butterfly.arbitrum-sepolia.quiknode.pro/b866a1312df26e5763237e1aff0a300bd4501647"
rpc_url = "wss://arbitrum-sepolia-rpc.publicnode.com,wss://rpc.ankr.com/arbitrum_sepolia,wss://arbitrum-sepolia.drpc.org/,wss://testnet-rpc.etherspot.io/v1/421614,wss://endpoints.omniatech.io/v1/arbitrum/sepolia/public,wss://arb-sepolia.g.alchemy.com/v2/4PDb7czJf8E6z7ZjhXB0Z5fdU1XaQT0u"
chain_id = 421614
controller_address = "0x4a83270045FB4BCd1bdFe1bD6B00762A9D8bbF4E"
payments_address = "0xdE7CEa09A23e7Aa4980B95F69B8912F39A0e323A"
Expand Down
17 changes: 13 additions & 4 deletions pkg/web3/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,19 @@ func NewContractSDK(options Web3Options) (*Web3SDK, error) {
displayOpts.PrivateKey = "*********"
log.Debug().Msgf("NewContractSDK: %+v", displayOpts)

client, err := ethclient.Dial(options.RpcURL)
if err != nil {
return nil, err
rpcs := strings.Split(options.RpcURL, ",")
var client *ethclient.Client
var err error
for _, url := range rpcs {
client, err = ethclient.Dial(url)
if err != nil {
log.Error().Msgf("Failed to connect to %s: %v", url, err)
continue
} else {
break
}
}

privateKey, err := ParsePrivateKey(options.PrivateKey)
if err != nil {
return nil, err
Expand Down Expand Up @@ -229,7 +238,7 @@ func NewContractSDK(options Web3Options) (*Web3SDK, error) {
TransactOpts: transactOpts,
Contracts: contracts,
}
log.Debug().Msgf("Public Address: %s", web3SDK.GetAddress())
log.Info().Msgf("Public Address: %s", web3SDK.GetAddress())

return web3SDK, nil
}
Expand Down

0 comments on commit 973f396

Please sign in to comment.