stacks-archive / stacks-transactions-js

The JavaScript library for generating Stacks 2.0 transactions
19 stars 17 forks source link

Testnet Address Generation #130

Closed AnasSaeed123 closed 3 years ago

AnasSaeed123 commented 3 years ago

I am giving input argument (TransactionVersion.Testnet) in c32address function

The value of TransactionVersion.Testnet is: 128

When making testnet address it gives me this error:

'Invalid version (must be between 0 and 31)'

psq commented 3 years ago

@AnasSaeed123 26 is the version to use for testnet addresses, not the value used for transactions. See https://github.com/blockstack/stacks-transactions-js/blob/f41adb10bc93327668ccf74f76a826d545196e6a/src/constants.ts#L89

AnasSaeed123 commented 3 years ago

@AnasSaeed123 26 is the version to use for testnet addresses, not the value used for transactions. See

https://github.com/blockstack/stacks-transactions-js/blob/f41adb10bc93327668ccf74f76a826d545196e6a/src/constants.ts#L89

It is using transaction version not address version.

See this:https://github.com/blockstack/stacks-transactions-js/blob/02cbef85dc26487ee40d6ca4e8484c6e485ae714/tests/src/keys-tests.ts#L42

AnasSaeed123 commented 3 years ago

@psq Thanks a lot for your reply. I have created address from address version and received tokens from faucet. But in this repository it is giving wrong input argument in address generation.

psq commented 3 years ago

the code is correct, you just need to dig a bit deeper, because it ends up translating the TansactionVersion.Testnet into the correct value: https://github.com/blockstack/stacks-transactions-js/blob/02cbef85dc26487ee40d6ca4e8484c6e485ae714/src/types.ts#L159-L160

AnasSaeed123 commented 3 years ago

@psq Thanks a lot.