Skip to content

Error -32000 (authentication needed: password or unlock) #8

@atifzia

Description

@atifzia

I think there is nothing wrong with the code below as I unlock the account first and then make transaction

package main

import (
	"fmt"
	"github.com/onrik/ethrpc"
	"log"
	"github.com/ethereum/go-ethereum/accounts/keystore"
	"github.com/ethereum/go-ethereum/accounts"
	"math/big"
)

func main() {
	client:=ethrpc.New("http://localhost:8545")
	_, err := client.Web3ClientVersion()
	if err != nil {
		log.Fatal("Error Connecting To Node : ",err)
	}
	ks := keystore.NewKeyStore(
		"/home/atif/.ethereum/rinkeby/keystore/",
		keystore.LightScryptN,
		keystore.LightScryptP)
	var unlockedAccount accounts.Account
	accs:=ks.Accounts()
	if err:=ks.Unlock(accs[1],"abcd");err==nil{
		unlockedAccount=accs[1]
		fmt.Println("Account Unlocked")
	}
	t:=ethrpc.T{
		From:  unlockedAccount.Address.Hex(),
		To:    "0x92dd679e2d8e107d8122ad5b3c868265e77c8af2",
		Gas:    123456,
		GasPrice:big.NewInt(12400000),
		Value:big.NewInt(20000000000),
		Data:"",
		Nonce:0,
	}
	txid, err := client.EthSendTransaction(t)
	if err != nil {
		log.Fatal("Transaction Error => ",err)
	}
	fmt.Println(txid)
}

What I want
txid of Real Transaction
What is get
Transaction Error => Error -32000 (authentication needed: password or unlock)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions