Closed alienzhangyw closed 9 months ago
It seems that it's a problem of TronLink Extension. I tried with my own tronWeb
instance and it works fine.
Please construct a new tronWeb instance and try the signMessageV2
method.
It seems that it's a problem of TronLink Extension. I tried with my own
tronWeb
instance and it works fine. Please construct a new tronWeb instance and try thesignMessageV2
method.
signMessageV2
works fine in Nodejs environment.
But shouldn't I use the TronLink injected tronWeb instance in browser? I'm developing a DAPP. I need to connect to user's wallet then sign messages and transactions.
Can you just sign the hash as a plain string? The following codes work fine.
const str = '0x4a3264ece439ed1a76ba692380cce39da2eb570b78b0572259fe8c0e528f30e6';
const res = await tronWeb.trx.signMessageV2(str);
const verifiedAddress = await tronWeb.trx.verifyMessageV2(str, res);
console.log('signed message: ', res, 'is valid: ', verifiedAddress === tronWeb.defaultAddress.base58);
It seems that TronLink does not process signMessageV2()
correctly as same as TronWeb
library. Also you can open an issue in TronLink developer community.
Can you just sign the hash as a plain string? The following codes work fine.
const str = '0x4a3264ece439ed1a76ba692380cce39da2eb570b78b0572259fe8c0e528f30e6'; const res = await tronWeb.trx.signMessageV2(str); const verifiedAddress = await tronWeb.trx.verifyMessageV2(str, res); console.log('signed message: ', res, 'is valid: ', verifiedAddress === tronWeb.defaultAddress.base58);
It seems that TronLink does not process
signMessageV2()
correctly as same asTronWeb
library. Also you can open an issue in TronLink developer community.
This is ok but we're verifing signature in smart contract, which can only treat the hash as byte32, not string type. Actually the hash itself is generated by the contract, if I treat it as a normal string in front-end, then the signature verification in contract will be failed.
We focus on TronWeb library. You could contact TronLink community to report this issue
I also reported this in the TronLink dev TG group. But nobody answers except some frauds.
Now I'm using signMessageV1
I have a hashed message to be signed: 0x4a3264ece439ed1a76ba692380cce39da2eb570b78b0572259fe8c0e528f30e6, According to TronWeb doc: https://tronweb.network/docu/docs/Sign%20and%20Verify%20Message
So I use TronWeb.utils.ethersUtils.arrayify to turn it to a Uint8Array with a length of 32. Then pass the Uint8Array to TronLinkAdapter.signMessage. Then I got this error from TronLink browser plugin: Failed to sign transaction by v2: Invalid transaction provided.![image](https://github.com/tronprotocol/tronweb/assets/58874541/597e4319-9247-47f6-94b3-a90a67816f8f)
Please tell me what is wrong.