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 create utxo lists from blockfrost APIs to use the UseLargestFirst method in Cardanosharp.Wallet? #17

Open
hparsafar opened this issue May 6, 2024 · 0 comments

Comments

@hparsafar
Copy link

this method is used to create a list of utxos in koios client.

`async Task<List> GetUtxos(string address)
{

var addressBulkRequest = new AddressBulkRequest { Addresses = new string[] { address } };
var addressResponse = (await addressClient.GetAddressInformation(addressBulkRequest));
var addressInfo = addressResponse.Content;
var utxos = new List<Utxo>();

foreach (var ai in addressInfo.SelectMany(x => x.UtxoSets))
{
    if (ai is null) continue;
    var utxo = new Utxo()
    {
        TxIndex = ai.TxIndex,
        TxHash = ai.TxHash,
        Balance = new Balance()
        {
            Lovelaces = ulong.Parse(ai.Value)
        }
    };

    var assetList = new List<CardanoSharpAsset>();
    foreach (var aa in ai.AssetList)
    {
        assetList.Add(new CardanoSharpAsset()
        {
            Name = aa.AssetName,
            PolicyId = aa.PolicyId,
            Quantity = long.Parse(aa.Quantity)
        });
    }

    utxo.Balance.Assets = assetList;
    utxos.Add(utxo);
}

return utxos;

}
`

but blockfrost API is not the same as koios in addressClient and GetAddressInformation does not return assets with policy id. could you please help me to write the same method for blockfrost?

@hparsafar hparsafar changed the title How to create lists from blockfrost APIs to use the UseLargestFirst method in Cardanosharp.Wallet? How to create utxo lists from blockfrost APIs to use the UseLargestFirst method in Cardanosharp.Wallet? May 6, 2024
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

1 participant