0

I'm facing a problem when I try to sign data with Nami Wallet API.

Here is the code snippet:

let namiAPI = await window.cardano.nami.enable();
let addr = await namiAPI.getUsedAddresses();
let payload = "48656C6C6F20576F726C6421"; //hex of "Hello World!"
let signed = await namiAPI.signData(addr.get(0), payload);

I get the following error:

{
    "code": 4,
    "info": "If a wallet enforces data format requirements, this error signifies that the data did not conform to valid formats."
}

What could be the problem? Am I encoding the payload wrong?

1 Answer 1

1

That payload looks good, just the address seems invalid. Probably need to access the array via addr[0] instead of addr.get(0), try this:

let namiAPI = await window.cardano.nami.enable();
let addr = await namiAPI.getUsedAddresses();
let payload = "48656C6C6F20576F726C6421"; //hex of "Hello World!"
let signed = await namiAPI.signData(addr[0], payload);

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.