I am having trouble sending my transaction Using Ganache. I am showing the logic that creates and sends the transaction and it says it cant be found or it is rejected don;t really know what the error message means. Couldn't find a fix about it might be a problem on Ganache side.
@app.route("/TransactionForm",methods=['GET','POST'])
@login_required
def Transaction():
form = TransactionForms()
if form.validate_on_submit():
if User.query.filter_by(username=form.sendTo.data).first() is not None:
user = User.query.filter_by(username=form.sendTo.data).first()
emailTo = user.email
usernameTo = user.username
publicKeyTo = user.public_key
passphrase = PassPhrase('english', user.password)
trans = CreateTransaction(GLink,current_user.public_key, publicKeyTo,1,21000, 20)
print(GLink.geth.personal.listAccounts())
SendTransaction(GLink,trans)
flash('Money Sent', 'success')
return redirect(url_for('account'))
elif User.query.filter_by(email=form.sendTo.data).first() is not None:
user = User.query.filter_by(email=form.sendTo.data).first()
emailTo = user.email
usernameTo = user.username
publicKeyTo = user.public_key
passphrase = PassPhrase('english', user.password)
trans = CreateTransaction(GLink,current_user.public_key,publicKeyTo,1, 21000, 20)
print(GLink.geth.personal.listAccounts())
SendTransaction(GLink,trans)
flash('Money Sent', 'success')
return redirect(url_for('account'))
else:
flash('Account Does Not Exist', 'danger')
return render_template('TransactionForm.html', title='TransactionForm', form=form)
def CreateTransaction(web3, account, to, value, gas, gasprice):
nonce = savedW.eth.getTransactionCount(account)
transaction = {
'nonce' : nonce,
'to' : to,
'value' : web3.toWei(value,'ether'),
'gas' : gas,
'gasPrice' : web3.toWei(gasprice,'gwei'),
'ChainID' : str(5777)
}
return transaction
def CreateTransaction2(web3,toA, value):
transaction = {
'to' : toA,
'value' : web3.toWei(value,'ether'),
}
return transaction
def SendTransaction(web3,transaction):
web3.eth.sendTransaction(transaction)
from
field in the transaction is missing. From is the sender of the transaction, address that will sign it.