1+ from typing import Optional
12import decimal
23
34from django .core .exceptions import ImproperlyConfigured
@@ -69,6 +70,7 @@ class IToken(object):
6970 TOKEN_AND_NETWORK_ID_COMBINED = None # {TOKEN_SYMBOL}-{NETWORK_IDENTIFIER}
7071 IS_NATIVE_ASSET = True # Not a token - e.g. ETH in L1.
7172 ADDRESS = None # If a token, then the smart contract address.
73+ EIP3091_EXPLORER_URL = None # if set, allows links to transactions to be generated
7274
7375 def __init__ (self ):
7476 self ._validate_class_variables ()
@@ -158,6 +160,19 @@ def get_balance_of_address(self, hex_wallet_address, rpc_url):
158160 )
159161 return token_contract .functions .balanceOf (checksum_address ).call ()
160162
163+ def get_transaction_link (self , transaction_hash : Optional [str ]) -> Optional [
164+ str ]:
165+ return '{base}/tx/{hash}' .format (
166+ base = self .EIP3091_EXPLORER_URL ,
167+ hash = transaction_hash ,
168+ )
169+
170+ def get_address_link (self , address : Optional [str ]) -> Optional [str ]:
171+ return '{base}/address/{address}' .format (
172+ base = self .EIP3091_EXPLORER_URL ,
173+ address = address ,
174+ )
175+
161176
162177""" L1 Networks """
163178
@@ -166,6 +181,7 @@ class L1(IToken):
166181 NETWORK_IDENTIFIER = "L1"
167182 NETWORK_VERBOSE_NAME = "Ethereum Mainnet"
168183 CHAIN_ID = 1
184+ EIP3091_EXPLORER_URL = "https://etherscan.io"
169185
170186 def payment_instructions (
171187 self , wallet_address , payment_amount , amount_in_token_base_unit
@@ -213,6 +229,7 @@ class RinkebyL1(L1):
213229 NETWORK_IDENTIFIER = "Rinkeby"
214230 NETWORK_VERBOSE_NAME = "Rinkeby Ethereum Testnet"
215231 CHAIN_ID = 4
232+ EIP3091_EXPLORER_URL = "https://rinkeby.etherscan.io"
216233
217234
218235class GoerliL1 (L1 ):
@@ -223,6 +240,7 @@ class GoerliL1(L1):
223240 NETWORK_IDENTIFIER = "Goerli"
224241 NETWORK_VERBOSE_NAME = "Goerli Ethereum Testnet"
225242 CHAIN_ID = 5
243+ EIP3091_EXPLORER_URL = "https://goerli.etherscan.io"
226244
227245
228246class EthRinkebyL1 (RinkebyL1 ):
@@ -290,6 +308,7 @@ class Optimism(L1):
290308 NETWORK_IDENTIFIER = "Optimism"
291309 NETWORK_VERBOSE_NAME = "Optimism Mainnet"
292310 CHAIN_ID = 10
311+ EIP3091_EXPLORER_URL = "https://optimistic.etherscan.io"
293312
294313
295314class KovanOptimism (Optimism ):
@@ -300,6 +319,7 @@ class KovanOptimism(Optimism):
300319 NETWORK_IDENTIFIER = "KovanOptimism"
301320 NETWORK_VERBOSE_NAME = "Kovan Optimism Testnet"
302321 CHAIN_ID = 69
322+ EIP3091_EXPLORER_URL = "https://kovan-optimistic.etherscan.io"
303323
304324
305325class EthKovanOptimism (KovanOptimism ):
@@ -349,6 +369,7 @@ class Arbitrum(L1):
349369 NETWORK_IDENTIFIER = "Arbitrum"
350370 NETWORK_VERBOSE_NAME = "Arbitrum Mainnet"
351371 CHAIN_ID = 42161
372+ EIP3091_EXPLORER_URL = "https://explorer.arbitrum.io"
352373
353374 def payment_instructions (
354375 self , wallet_address , payment_amount , amount_in_token_base_unit
@@ -391,6 +412,7 @@ class RinkebyArbitrum(Arbitrum):
391412 NETWORK_IDENTIFIER = "RinkebyArbitrum"
392413 NETWORK_VERBOSE_NAME = "Rinkeby Arbitrum Testnet"
393414 CHAIN_ID = 421611
415+ EIP3091_EXPLORER_URL = "https://rinkeby-explorer.arbitrum.io"
394416
395417
396418class ETHRinkebyArbitrum (RinkebyArbitrum ):
0 commit comments