0

Hi I am trying to sign a message using solana/wallet-adapter and gets error: "Cannot sign transaction using sign message"

code example below, Solflare and Wallet Connect treats Uint8Array encoded message fine, so trying to figure out

import { serialize } from 'borsh';
const message = new Mail({
from: new Person({
name: 'Cow',
wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
}),
to: new Person({
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
}),
contents: 'Hello, Bob!'
});
// Serialize the data
const serializedData = serialize(schema, message);
// Sign the serialized data
const signature = await phantomWalletProvider.signMessage(serializedData);

this variant doesnt work also:

signature = await walletProvider.signMessage(new TextEncoder().encode(JSON.stringify(message)));

1 Answer 1

3

it looks like you have some Ethereum addresses in that message you're signing. Could you please confirm if you're trying to sign a message on Solana? If so, could you please double check that you are passing either a hex or UTF-8 encoded string as a Uint8Array? Phantom's signMessage method on Solana will only accept UTF-8 or hex encoded strings (see docs). For a live example, please see our sandbox and its accompanying signMessage function.

1
  • I changed to solana addresses, with same result. that is just an example of some serialized object to be subscribed Feb 8 at 14:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.