Sign not working due to non base 58 character

Hi there,

I am trying to create a spendTx transaction, i’ve done so both through the ‘/debug/transactions/spend’ endpoint as well as through the new Transaction().spendTx() SDK function. Both functions return a string in the format tx_+EsMAaEBuaOJ/QXTInlxWiHEiC+GIjABsRmJIot9Ou2vsUjvkdqhAYOExyyB2qUAYqPCJkecKeea9JGT9jdP4vbY2Gzq+TyNCgEBAIBQtJf4

Once i try to sign the transaction according to . I get the error Error: Non-base58 character. (which is correct the + and / characters are not included in base58, this looks like base64). I’ve tried replacing “const binaryTx = Crypto.decodeBase58Check(base58CheckTx)” with “const binaryTx = Crypto.decodeBase64Check(base58CheckTx)”, but this resulted in an invalid tx.
Any idea what i can do to make this work?

The transaction (prefixed tx_) is indeed Base64Check encoded. Your transaction looks just fine to me:

24> {_, TX} = aeser_api_encoder:decode(<<"tx_+EsMAaEBuaOJ/QXTInlxWiHEiC+GIjABsRmJIot9Ou2vsUjvkdqhAYOExyyB2qUAYqPCJkecKeea9JGT9jdP4vbY2Gzq+TyNCgEBAIBQtJf4">>).
25> aetx:deserialize_from_binary(TX).                                                                                                                         

But unfortunately I don’t know enough about the SDK to point you to the right functions there. The linked instructions seems to be missing the step where you add the network_id to the serialized transaction, but again the SDK is uncharted territory for me… Maybe @nduchak.chain can clarify?

Hey @Kenyre, please take a look at this method.
This is exactly the place where signing happens Also, you can take a look on the guide for low-lvl usage. But still I recommend you to use hight LVL SDK API for that. this doc is deprecated and will be fixed soon

1 Like

thanks a lot for the reply!
When using i get the error “There must be spendTx in this stamp methods” maybe because my internal endpoint is wrongly formatted? (debug is enabled in the .yaml) I use the following endpoints:
let url = ‘http ://localhost:3013’
let internalUrl = ‘http ://localhost:3113’
(spaces in url because i wasnt allowed to post more than 2 urls)
The error arises before anything is done on the spendTx, so i recon it is due to wrong settings.

I’ll try building my own sign from the other url you provided. Problem is i don’t want any of the private keys stored in the node (i have my own database for keys). Do you know if using the Account({}) from the SDK places the keys in some sort of keystore?

SO basically SDK is storing your keys in memory if you need to store your keys in the database you probably can use the keystore from SDK for that. The question is why are you not using high-lvl API of SDK?
If you don’t want to store you privateKey in SDK then you need to provided using onAccount option for each operation

const sdkInstance = await Universal({ ... }) // 
await sdkInstance.spend(amount, recipient, { onAccount: { secretKey: 'YOUR_PRIV', publicKey: 'YOUR_PUB' } })

I am not using the high level SDK, since with most coins this means your keys are stored in the local keystore. My database where i store the keys is more secure than the node where the syncing is done. Furthermore the format for saving userData has to be the same over all different coins.

I’ll try it with the onAccount, thanks for the support.

1 Like

Can you elaborate further please? The official erlang node does not use or store any account keys. I assume you’re referring to it as you wrote “where syncing is done”.

1 Like