def __init__(self): self.env = BinanceEnvironment( api_url='https://dex-asiapacific.binance.org', wss_url='wss://dex.binance.org/api/', hrp='bnb') with open('bnb_real_key.txt', 'r') as f: key = f.readline() # for testing # self.env = BinanceEnvironment.get_testnet_env() # with open('bnb_key.txt', 'r') as f: # key = f.readline() f.close() self.client = HttpApiClient(env=self.env) self.wallet = Wallet(key, env=self.env) self.address = self.wallet.address self.ftx = ccxt.ftx({ 'apiKey': '6p37l5AXOzIgFzfeSzkcuPhuaYcw3GcpJrU83ROy', 'secret': '3SphoJJ6Gl_w5pPPkGmQpKbVGN9oPiUgxqs4ob_H' }) #self.assets = ['USD', 'USDT'] self.assets = ['USD'] self.BNB_BUSD = 'BNB.BUSD-BD1' self.pool = THORChain()
def __init__(self): self.env = BinanceEnvironment.get_testnet_env() self.client = HttpApiClient(env=self.env) with open('secret/bnb_key.txt', 'r') as f: key = f.readline() self.wallet = Wallet(key, env=self.env) self.address = self.wallet.address driver_logger.info(f'bnb address: {self.address}')
def __init__(self, env, private_key_string, symbol): self.test_net_url = "https://testnet-dex.binance.org/" self.main_net_url = "https://dex.binance.org/" self.symbol = symbol self.env = env self.private_key_string = private_key_string self.wallet = Wallet(private_key=private_key_string, env=self.env) self.cli = HttpApiClient(env=self.env, api_url=self.main_net_url)
async def test_depthcache_create(self, event_loop, env): async def callback(_depth_cache): pass client = HttpApiClient(env=env) dcm1 = await DepthCacheManager.create(client, event_loop, "MITH-C76_BNB", callback, env=env) assert dcm1 assert dcm1.get_depth_cache() await dcm1.close()
def freeze_bnb_wish(amount): freeze_env = BinanceEnvironment.get_production_env() if NETWORK_SIGN_TRANSACTION_BWISH == 'testnet': freeze_env = BinanceEnvironment.get_testnet_env() client = HttpApiClient(env=freeze_env) bep_wallet = Wallet(BINANCE_PAYMENT_PASSWORD, env=freeze_env) # from settings value = float(amount / 10**18) freeze_msg = TransferMsg(wallet=bep_wallet, symbol=COLD_TOKEN_SYMBOL_BNB, amount=value, to_address=COLD_BNB_ADDRESS, memo='freeze bnb wish') res = client.broadcast_msg(freeze_msg, sync=True) print('result', res, flush=True) if not res[0]['ok']: raise Exception('cannot make bnb wish freeze tx')
def __init__(self, key, test=False): self.BUSD = 'BUSD-BD1' self.BNB = 'BNB' self.pairs = [] self.bnb_pairs = {} self.busd_pairs = {} self.api_instance = binance_client.DefaultApi() if test: self.env = BinanceEnvironment.get_testnet_env() self.RUNE = 'RUNE-67C' self.api_instance.api_client.configuration.host = self.env.api_url + '/api' else: self.env = BinanceEnvironment(api_url='https://dex-european.binance.org', wss_url='wss://dex.binance.org/api/', hrp='bnb') self.RUNE = 'RUNE-B1A' binance_logger.info(f'Binance connected to node: {self.env.api_url}') self.client = HttpApiClient(env=self.env) self.wallet = Wallet(private_key=key, env=self.env) self.wallet.reload_account_sequence() self.account_info()
def httpclient(self, env): return HttpApiClient(env=env)
from scanner.blockchain_common.wrapper_block import WrapperBlock from scanner.blockchain_common.wrapper_network import WrapperNetwork from scanner.blockchain_common.wrapper_output import WrapperOutput from scanner.blockchain_common.wrapper_transaction import WrapperTransaction from scanner.eventscanner.queue.pika_handler import send_to_backend from binance_chain.exceptions import BinanceChainAPIException from binance_chain.http import HttpApiClient from binance_chain.http import PeerType from binance_chain.constants import KlineInterval from binance_chain.environment import BinanceEnvironment from binance_chain.node_rpc.http import HttpRpcClient #Setting Binance-Chain params, testnet_env for testnet client = HttpApiClient(request_params={"verify": False, "timeout": 60}) #client = HttpApiClient() #testnet_env = BinanceEnvironment.get_testnet_env() #client = HttpApiClient(env=testnet_env, request_params={"verify": False, "timeout": 60}) peers = client.get_node_peers() listen_addr = peers[0]['listen_addr'] rpc_client = HttpRpcClient(listen_addr) processed = [] commited = [] class BinNetwork(WrapperNetwork): BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) base_dir = 'scanner/settings'
def httpclient(self, env): return HttpApiClient(env=env, requests_params={'timeout': 1})
def _get_http_client(self): if not self._http_client: from binance_chain.http import HttpApiClient self._http_client = HttpApiClient(self._env) return self._http_client
from binance_chain.environment import BinanceEnvironment from binance_chain.http import HttpApiClient from binance_chain.wallet import Wallet testnet_env = BinanceEnvironment.get_testnet_env() client = HttpApiClient(env=testnet_env) def make_binance_wallet(): wallet = Wallet.create_random_wallet(env=testnet_env) print(wallet.address) print(wallet.private_key) print(wallet.public_key_hex) return wallet.address
from blockchain_common.eth_tokens import erc20_abi from blockchain_common.wrapper_block import WrapperBlock from blockchain_common.wrapper_network import WrapperNetwork from blockchain_common.wrapper_output import WrapperOutput from blockchain_common.wrapper_transaction import WrapperTransaction from blockchain_common.wrapper_transaction_receipt import WrapperTransactionReceipt from settings.settings_local import NETWORKS, ERC20_TOKENS from binance_chain.http import HttpApiClient from binance_chain.http import PeerType from binance_chain.constants import KlineInterval from binance_chain.environment import BinanceEnvironment from binance_chain.node_rpc.http import HttpRpcClient client = HttpApiClient(request_params={"verify": False, "timeout": 20}) httpapiclient = HttpApiClient() peers = httpapiclient.get_node_peers() listen_addr = peers[0]['listen_addr'] rpc_client = HttpRpcClient(listen_addr) processed = [] commited = [] class BinNetwork(WrapperNetwork): BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.append(BASE_DIR) base_dir = 'settings' def __init__(self, type): super().__init__(type)