how I can get users collateral address from wallet?
I am using nft-maker-pro for creating a small NFT market place. I need collateral address for that like https://d-wallet-playground.yellowhouse.gmbh/wallet this.
Cardano Stack Exchange is a question and answer site for users and developers of the Cardano cryptocurrency ecosystem. It only takes a minute to sign up.
Sign up to join this communityhow I can get users collateral address from wallet?
I am using nft-maker-pro for creating a small NFT market place. I need collateral address for that like https://d-wallet-playground.yellowhouse.gmbh/wallet this.
I am not familiar with the tool but the collateral is usually provided by whoever is creating the transaction to be submitted. And as long as a smart contract isn't being run and fails during validation your collateral is save.
So if you use a light wallet like nami send yourself 5-10 ADA and use that as collateral.
According to CIP-30
"api.getCollateral()"
so you can get it in your react application by using:
const api = await window.cardano[WALLET-NAME].enable()
const changeAddress = await api.getCollateral()
The easiest way to get a collateral UTXO is to use a library like Helios which is both an on-chain smart contract Plutus compiler and an off-chain transaction builder. Helios has some convenience wrappers/helpers for working with CIP30 spec so you don’t have to do the CBOR conversions for example.
Here is the code.
// Determine the UTXO used for collateral
const colatUtxo = await walletHelper.pickCollateral();
tx.addCollateral(colatUtxo);
Or if you need the change wallet address, you can use.
// Get change address
const changeAddr = await walletHelper.changeAddress;
Check out the full source code here in my Helios examples repo: https://github.com/lley154/helios-examples/blob/main/nft/pages/index.tsx