#Error casting in soroban-js-sdk.

5 messages · Page 1 of 1 (latest)

frail latch
#

Hello!! I'm trying to write a code for JS trying to invoke a soroban contract, but it throws me an error. Do you know what could be? The error thrown is XDR Write Error: got 56 bytes, expected 32.
Here is the piece of code that throws me that error.

const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey);
const sourcePublicKey = sourceKeypair.publicKey();
xdr.ScVal.scvAddress(    xdr.ScAddress.scAddressTypeAccount(
xdr.PublicKey.publicKeyTypeEd25519(sourcePublicKey))),

I'm starting with this SDK, so i don't really know much. Thank you!!

#

Error casting in soroban-js-sdk.

stark sage
#

the public key needs to be the raw pub key

indigo musk
#

Hey @frail latch you should use Keypair.rawPublicKey to get the Buffer of the pub key

wild spruce
#

btw since you're using it to get the ScVal, just do: new Address(PUBLIC_KEY).toScVal(). The function will take care of the rest