├── README.md └── send.py /README.md: -------------------------------------------------------------------------------- 1 | # sendTransactionsonBSC 2 | 3 | everything explained in this video 4 | https://youtu.be/lDkHG_iE0oA 5 | -------------------------------------------------------------------------------- /send.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | import json 3 | import config 4 | 5 | bsc = "https://bsc-dataseed.binance.org/" 6 | web3 = Web3(Web3.HTTPProvider(bsc)) 7 | 8 | print(web3.isConnected()) 9 | 10 | main_address= "" 11 | contract_address = 'CONTRACT_ADDRESS' #be sure to use a BSC Address in uppercase format like this 0x9F0818B... 12 | 13 | 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"}]') 14 | 15 | contract = web3.eth.contract(address=contract_address, abi=abi) 16 | 17 | totalSupply = contract.functions.totalSupply().call() 18 | 19 | print(web3.fromWei(totalSupply, 'ether')) 20 | 21 | print(contract.functions.name().call()) 22 | print(contract.functions.symbol().call()) 23 | 24 | 25 | balanceOf = contract.functions.balanceOf(main_address).call() 26 | print(web3.fromWei(balanceOf, 'ether')) 27 | 28 | me = '0x5977987.....' #send from this address 29 | main_address= "0x9F....." #to this address 30 | 31 | send = 1000 32 | amount = web3.toWei(send, 'ether') 33 | print(amount) 34 | 35 | nonce = web3.eth.getTransactionCount(me) 36 | print(nonce) 37 | 38 | token_tx = contract.functions.transfer(main_address, amount).buildTransaction({ 39 | 'chainId':56, 'gas': 100000,'gasPrice': web3.toWei('10','gwei'), 'nonce':nonce 40 | }) 41 | sign_txn = web3.eth.account.signTransaction(token_tx, private_key=YOURPRIVATEKEY) 42 | web3.eth.sendRawTransaction(sign_txn.rawTransaction) 43 | print(f"Transaction has been sent to {main_address}") 44 | --------------------------------------------------------------------------------