0

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)

Error Message Here

4
  • The error message says the from field in the transaction is missing. From is the sender of the transaction, address that will sign it.
    – Ismael
    Commented Jun 28, 2020 at 0:34
  • @Ismael But I thought I had that handled through the nonce.
    – Choppa200
    Commented Jun 28, 2020 at 2:12
  • They are different things: nonce is a number, and from is an address.
    – Ismael
    Commented Jun 28, 2020 at 3:39
  • @Ismael Yup! didn't realize i missed the "from" I kind of assumed since the documentation said it was optional that the function had the "from" handled.
    – Choppa200
    Commented Jun 28, 2020 at 4:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.