Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the collateral address of a connect wallet? #424

Closed
Reaziii opened this issue Apr 13, 2022 · 1 comment
Closed

How to get the collateral address of a connect wallet? #424

Reaziii opened this issue Apr 13, 2022 · 1 comment

Comments

@Reaziii
Copy link

Reaziii commented Apr 13, 2022

How to get the collateral address of a connect wallet?

@rooooooooob
Copy link
Contributor

@Reaziii I'm not sure if this is an issue for cardano-serialization-lib. This library is client-side entirely and has no wallet information. It is used by quite a few wallets internally though. Are you talking about the CIP-30 for dApps (webpages) connecting to wallets? If so the API is here. As you can see there is no endpoint. It's possible some wallets will put it in the api.experimental, but that should not be depended on. From what I understand, it's a bit of a wallet-specific concept so a wallet might not necessarily have a single collateral address, and it might depend on what kind of transaction you'd trying to construct, how much it needs, etc. See cardano-foundation/CIPs/pull/104 which is an attempt to standardize it for light wallets. It looks like there are going to be some changes (collateral outputs) in Babbage so I don't expect there to be any standardization on a possible CIP-0030 endpoint before that and maybe make this no longer needed. I did notice that recently (8 days ago) however a api.getCollateral(amont: cbor<Coin>) -> TransactionUnspentOutput[] endpoint was added, which gives you a list of inputs which it would pick for a transaction that needs amount covered. Since it's so recent it might not be available on all wallets. If you're asking about how to decode that information using cardano-serialization-lib, then just use let inputs = TransactionUnspentOutputs.from_bytes(hexBytes) where hexBytes is the decoded hex string returned by that function. See the struct here to see what info that provides. i.e. inputs.get(index).output.address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants