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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| from web3 import Web3
abi = """[ { "inputs": [ { "internalType": "uint256", "name": "times", "type": "uint256" } ], "name": "call", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "times", "type": "uint256" } ], "name": "callnodest", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ] """
w3 = Web3(Web3.HTTPProvider("https://data-seed-prebsc-1-s1.binance.org:8545")) contract = "0x10373DA73C47b09E3d35199175A9cec7d7Cbc585"
contractObj = w3.eth.contract( address=Web3.toChecksumAddress(contract), abi=abi)
tx_dic1 = contractObj.functions.call(10). \ buildTransaction( { 'gas': 15000000, } )
tx_dic2 = contractObj.functions.callnodest(10). \ buildTransaction( { 'gas': 15000000, } )
def send_transaction(tx_dic, wallet_address, wallet_private): nonce = w3.eth.getTransactionCount(wallet_address) tx_dic["nonce"] = nonce tx_dic['gasPrice'] = w3.toWei(20, 'gwei') sign_tx = w3.eth.account.signTransaction(tx_dic, private_key=wallet_private) txn_hash = w3.eth.sendRawTransaction(sign_tx.rawTransaction) return Web3.toHex(txn_hash)
# tx1 = send_transaction(tx_dic1, "address", # "private")
tx2 = send_transaction(tx_dic1, "address", "private")
|