Eth_sign and personal sign

Hey there,
I am currently signing a trnsaction using eth_sign. It works with eth_sign but I wanna use personal_sign instead. When I do that it doesnt work.

Old that works:

                await web3.eth.sign(rawHash, walletAddress)

New that doesnt work

                await web3.eth.personal.sign(rawHash, walletAddress)

Error when using personal sign:
MetaMask - RPC Error: insufficient funds for gas * price + value

Why is that ?

usually you sign a message with personal signs, not a transaction hash, did you try to sing a simple text message?

no im signing a transaction object that interacts with my smart contract.

I dont wanna use teh sign anymore since it might get removed by metamask soon. So I tried using personal sign. It should work the same, not ?

try it with a text message first to see if it works for you, you should be able to easily do what you want to do

works with a text message but it doesnt with a transaction like eth_sign

I get MetaMask - RPC Error: insufficient funds for gas * price + value
And i dont get it with eth_sign

are you sure that is the right syntax for personal sign? what library is used there? you can also look in Moralis SDK to see how personal sign is used to sign a message

But its not a message i am signing. I am signing a transaction using ethereum-tx.js libary.

You can see the diffent signing methods here.

hope you understand now. I am stuck at this for a very long time :frowning:

I know the difference between the sign methods. Did you try it with a simple text message just to see if you got the syntax right?

yes I did. I need it for a trnsaction though. When I do it with transaction i get this error

MetaMask - RPC Error: insufficient funds for gas * price + value

what is the difference then? are you sure that is the issue?

thats the error i am getting when using personal sign

this syntax should work without issues:

signature = await web3.eth.personal.sign(data, ethAddress, '');

are you sure you are running this code and not something else?

this works without issues for me:

signature = await web3.eth.personal.sign("\x34\x45", "address_here", '');

i get the error when I try to send the signed transaction. My bad. Still why is that ?

can you give en example that I could test, like the actual value for the data parameter?

It looks like that similary


                let hexGasPrice  = web3.utils.toHex(Math.floor(gasPrice * 1.3))
                const transactionObject = {
                    nonce: web3.utils.toHex(trasnaction),
                    gasPrice: hexGasPrice,
                    gasLimit: '0x55F0',
                    to: receive,
                    value: '0x',
                    data: encodedABI,
                }

                let hexObject = new ethereumjs.Tx(transactionObject);
                let hexString = '0x' + hexObject.serialize().toString('hex'),
                    encoded = {
                        encoding: 'hex'
                    }
                const rawHash = web3.utils.sha3(hexString, encoded);


                await web3.eth.personal.sign(rawHash, walletAddress, '').then(hash => {
                        await web3.eth.sendSignedTransaction(signedTrans).....

};

what is this?

here, you could use a console log for that rawHash, and get the signature value with await

                    const signedTrans = '0x' + hexObject.serialize().toString('hex');
                    console.log(signedTrans);

thats the signed trans.

Yeah I logged it now. Didnt change much :frowning: