Eth_sign and personal sign

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:

you can not send a singed transaction hash that was signed with personal sign as you would send a normal transaction, you can only save the signature and validate it, it will not be mined on chain as a normal transaction

with eth_sign it works. Any alternative to eth_sign ?

I don’t understand what you want to do

that is something that will happen when you try to sign a binary message, it doesn’t look like you got into that issue yet

i still get this scary warning for some reason(

usually you use personal sign to sign text data, for example you can convert binary data to hex so that it is showed as text

i tried rn converting "hello world " to a hex and signing that with eth_sign. The scray warning is still there. I need eth:sign. Its the only method sending transactions. Thats really sad tbh. Maybe there are different methods