Sumber daya yang dimuat... Pemuatan...

Transaksi BSC

Penulis:Kacang polong, Tanggal: 2021-03-17 21:58:05
Tag:Alat

Apa yang terjadi? Beberapa hari yang lalu, sebuah penelitian baru yang dilakukan oleh para peneliti menemukan bahwa transfer uang secara otomatis melalui rantai... Tidak, tidak, tidak, tidak, tidak, tidak, tidak. Saya tidak tahu apa yang terjadi di sini. Semoga kalian semua kaya!



from web3 import Web3
import json
import time
import urllib.request

def transaction(my_address, to_address, contract_address, private_key, send, gas):
    Log("start trans " + contract_coin)
    bsc = "https://bsc-dataseed.binance.org/"
    web3 = Web3(Web3.HTTPProvider(bsc))

    Log(web3.isConnected())

    balance = web3.eth.get_balance(my_address)
    humanReadalbe = web3.fromWei(balance, 'ether')
    Log(humanReadalbe)

    abi = json.loads('[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}]')

    nonce = web3.eth.getTransactionCount(my_address)

    contract_address = web3.toChecksumAddress(contract_address)
    contract = web3.eth.contract(address=contract_address, abi=abi)

    amount = web3.toWei(send, 'ether')
    Log(amount)

    token_tx = contract.functions.transfer(to_address, amount).buildTransaction({
        'chainId':56, 'gas': 150000,'gasPrice': web3.toWei(gas,'gwei'), 'nonce':nonce
    })
    sign_txn = web3.eth.account.signTransaction(token_tx, private_key=private_key)
    web3.eth.sendRawTransaction(sign_txn.rawTransaction)
    Log("Transaction has been sent to " + to_address)

def transaction_bnb(my_address, to_address, private_key, send, gas):
    Log("start trans " + contract_coin)
    bsc = "https://bsc-dataseed.binance.org/"
    web3 = Web3(Web3.HTTPProvider(bsc))

    Log(web3.isConnected())

    balance = web3.eth.get_balance(my_address)
    humanReadalbe = web3.fromWei(balance, 'ether')
    Log(humanReadalbe)

    nonce = web3.eth.getTransactionCount(my_address)

    tx = {
        'nonce': nonce,
        'to': to_address,
        'value': web3.toWei(send, 'ether'),
        'gas': 150000,
        'gasPrice': web3.toWei(gas, 'gwei')
    }

    try:
        signed_tx = web3.eth.account.signTransaction(tx, private_key)
        tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
        trans = web3.toHex(tx_hash)
        Log(trans)
        transaction = web3.eth.get_transaction(trans)
        Log("get " + trans + " status!!")
    except IOError:
        Sleep(100)
        signed_tx = web3.eth.account.signTransaction(tx, private_key)
        tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
        trans = web3.toHex(tx_hash)
        Log("get hash error retry!!")
        transaction = web3.eth.get_transaction(trans)
        Log("get " + trans + " status!!")
    else:
        trans_reslut = web3.eth.waitForTransactionReceipt(tx_hash, timeout=30, poll_latency=0.1)
        trans_reslut = web3.toJSON(trans_reslut)
        Log(trans_reslut)
        trans_reslut_status = json.loads(trans_reslut)['status']
        Log(trans_reslut_status)
        if trans_reslut_status == 0:
            Log("trans failed retry!!")
            transaction_bnb(my_address, to_address, private_key, send, gas)


def doAction():
    Log("Start trasaction!!!")
    if contract_coin != 'BNB':
        transaction(my_address, to_address, contract_address, private_key, send, gas)
    else:
        transaction_bnb(my_address, to_address, private_key, send, gas)
    pass
    Log("trasaction Done!!!")

def main():
    LogReset()
    while 1:
        if time.time() > transaction_time:
            Log("Is time to gogogo !!!")
            Log(_D(time.time()))
            doAction()
            exit("End!!!")
        pass


    


Berkaitan

Lebih banyak

SsssuoswBagaimana dengan rekor baru?

rootmeKacang selalu indah.

FmzeroSapi sapi sapi