Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit b5e008c

Browse files
Use new universal RPC endpoint (#109)
1 parent bda59e4 commit b5e008c

File tree

3 files changed

+454
-405
lines changed

3 files changed

+454
-405
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"devDependencies": {
3-
"hardhat": "^2.9.2"
3+
"hardhat": "^2.12.0"
44
}
55
}

thirdweb/constants/urls.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
PINATA_IPFS_URL = "https://api.pinata.cloud/pinning/pinFileToIPFS"
99

10-
DEFAULT_API_KEY = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"
10+
DEFAULT_API_KEY = "39a3c037d7a88e6692c6681bccfd1f1cf36370324c4051a83acd0edcffb20708"
1111

12+
def get_rpc_url(network: str) -> str:
13+
return f"https://{network}.rpc.thirdweb.com/{DEFAULT_API_KEY}"
1214

1315
def get_provider_for_network(network: str) -> Web3:
1416
"""
@@ -17,19 +19,25 @@ def get_provider_for_network(network: str) -> Web3:
1719

1820
rpc_url = ""
1921
if network == "mainnet" or network == "ethereum":
20-
rpc_url = f"https://eth-mainnet.g.alchemy.com/v2/{DEFAULT_API_KEY}"
21-
elif network == "rinkeby":
22-
rpc_url = f"https://eth-rinkeby.g.alchemy.com/v2/{DEFAULT_API_KEY}"
22+
rpc_url = get_rpc_url("ethereum")
2323
elif network == "goerli":
24-
rpc_url = f"https://eth-goerli.g.alchemy.com/v2/{DEFAULT_API_KEY}"
24+
rpc_url = get_rpc_url("goerli")
2525
elif network == "polygon":
26-
rpc_url = f"https://polygon-mainnet.g.alchemy.com/v2/{DEFAULT_API_KEY}"
26+
rpc_url = get_rpc_url("polygon")
2727
elif network == "mumbai":
28-
rpc_url = f"https://polygon-mumbai.g.alchemy.com/v2/{DEFAULT_API_KEY}"
28+
rpc_url = get_rpc_url("mumbai")
29+
elif network == "optimism":
30+
rpc_url = getRpcUrl("optimism");
31+
elif network == "optimism-goerli":
32+
rpc_url = getRpcUrl("optimism-goerli");
33+
elif network == "arbitrum":
34+
rpc_url = getRpcUrl("arbitrum");
35+
elif network == "arbitrum-goerli":
36+
rpc_url = getRpcUrl("arbitrum-goerli");
2937
elif network == "fantom":
30-
rpc_url = "rpc.ftm.tools"
38+
rpc_url = get_rpc_url("fantom")
3139
elif network == "avalanche":
32-
rpc_url = "https://rpc.ankr.com/avalanche"
40+
rpc_url = get_rpc_url("avalanche")
3341
else:
3442
if network.startswith("http"):
3543
rpc_url = network

0 commit comments

Comments
 (0)