Client

class ScanWatch.Client.Client(api_token: str, nt_type: ScanWatch.utils.enums.NETWORK, net: str = 'main')[source]

Client the API: https://etherscan.io/apis https://bscscan.com/apis https://polygonscan.com/apis

BASE_URLS = {<NETWORK.BSC: 2>: {'main': 'https://api.bscscan.com/api', 'test': 'https://api-testnet.bscscan.com/api'}, <NETWORK.ETHER: 1>: {'main': 'https://api.etherscan.io/api', 'goerli': 'https://api-goerli.etherscan.io/api', 'kovan': 'https://api-kovan.etherscan.io/api', 'rinkeby': 'https://api-rinkeby.etherscan.io/api', 'ropsten': 'https://api-ropsten.etherscan.io/api'}, <NETWORK.POLYGON: 3>: {'main': 'https://api.polygonscan.com/api', 'test': 'https://api-testnet.polygonscan.com/api'}}
__init__(api_token: str, nt_type: ScanWatch.utils.enums.NETWORK, net: str = 'main')[source]
Parameters
  • api_token (str) – token for the api

  • nt_type (NETWORK) – type of the network

  • net (str, default 'main') – name of the network, used to differentiate main and test nets

get_balance(address: str) float[source]

fetch the current balance of an address

Parameters

address (str) – address

Returns

ETH amount

Return type

float

get_erc20_transactions(address: str, start_block: Optional[int] = None, end_block: Optional[int] = None)[source]

fetch erc20 transactions on an address

Parameters
  • address (str) – address

  • start_block (Optional[int]) – fetch transactions starting with this block

  • end_block (Optional[int]) – fetch transactions until this block

Returns

List of transactions

Return type

List[Dict]

[{'blockNumber': '108941',
  'timeStamp': '148216518',
  'hash': '0948461czecc9ze8e4vsvbq94sd96',
  'nonce': '23908745',
  'blockHash': '0x74a984dz56c13v8ze9q451vda',
  'from': 'zazd9f1wsqda84zds5qd6zda',
  'contractAddress': 'azd984f1edazdadqfefa',
  'to': '84cazd984csgzefa984zq5s1c',
  'value': '15248960000000000000',
  'tokenName': 'ChainLink Token',
  'tokenSymbol': 'LINK',
  'tokenDecimal': '18',
  'transactionIndex': '45',
  'gas': '200001',
  'gasPrice': '100000000000',
  'gasUsed': '51481',
  'cumulativeGasUsed': '1491504',
  'input': 'deprecated',
  'confirmations': '1948513'},
...
]
get_erc721_transactions(address: str, start_block: Optional[int] = None, end_block: Optional[int] = None)[source]

fetch erc721 transactions on an address

Parameters
  • address (str) – address

  • start_block (Optional[int]) – fetch transactions starting with this block

  • end_block (Optional[int]) – fetch transactions until this block

Returns

List of transactions

Return type

List[Dict]

get_internal_transactions(address: str, start_block: Optional[int] = None, end_block: Optional[int] = None)[source]

fetch internal transactions on an address

Parameters
  • address (str) – address

  • start_block (Optional[int]) – fetch transactions starting with this block

  • end_block (Optional[int]) – fetch transactions until this block

Returns

List of transactions

Return type

List[Dict]

get_mined_blocks(address: str, start_block: Optional[int] = None, end_block: Optional[int] = None)[source]

fetch mined blocks by an address

Parameters
  • address (str) – network address

  • start_block (Optional[int]) – fetch mined blocks starting with this block

  • end_block (Optional[int]) – fetch mined blocks until this block

Returns

List of mined blocks

Return type

List[Dict]

get_normal_transactions(address: str, start_block: Optional[int] = None, end_block: Optional[int] = None)[source]

fetch normal transactions on an address

Parameters
  • address (str) – address

  • start_block (Optional[int]) – fetch transactions starting with this block

  • end_block (Optional[int]) – fetch transactions until this block

Returns

List of transactions

Return type

List[Dict]

[{'blockNumber': '10272495',
  'timeStamp': '1485965131',
  'hash': 'd9azfv1q9zf84zr15f49f49zef1z3sd1g98t1b6',
  'nonce': '9846651',
  'blockHash': 'zad94v16s1qef9a4f9v1r53b1sq64daf',
  'from': '496a1ef65s1dbv4a96z513svez965q',
  'contractAddress': 'az41f8ze1f63q5s1gv89ez49',
  'to': 'az49f84161ac89s4ef984a96e',
  'value': '17854000000000000000',
  'tokenName': 'ChainLink Token',
  'tokenSymbol': 'LINK',
  'tokenDecimal': '18',
  'transactionIndex': '79',
  'gas': '200001',
  'gasPrice': '100000000000',
  'gasUsed': '84215',
  'cumulativeGasUsed': '1531404',
  'input': 'deprecated',
  'confirmations': '119452'},
...
]
static get_result(url: str)[source]

call the API with an url, raise if the status is not ok and return the API result

Parameters

url (str) – url to request

Returns

API result

Return type

depend of the endpoint

get_url_request(**kwargs) str[source]

Construct the url to make a request to the API

Parameters

kwargs (Any) – keywords args for the endpoint

Returns

Return type