-
Notifications
You must be signed in to change notification settings - Fork 14
/
tokens.py
28 lines (22 loc) · 891 Bytes
/
tokens.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json, requests
from config import b_web3
from config import BscScan_key
def get_abi(address):
api_link = f'https://api.bscscan.com/api?module=contract&action=getabi&address={address}&apikey={BscScan_key}'
api_link_dump = (requests.get(api_link)).json()
abi = api_link_dump.get('result')
return json.loads(abi)
class pair:
def __init__(self,address):
self.address = b_web3.toChecksumAddress(address)
def createContract(self):
json_abi = get_abi(self.address)
contract = b_web3.eth.contract(address= self.address, abi= json_abi)
return contract
class token:
def __init__(self,address):
self.address = b_web3.toChecksumAddress(address)
def createContract(self):
json_abi = get_abi(self.address)
contract = b_web3.eth.contract(address= self.address, abi= json_abi)
return contract