Giter Site home page Giter Site logo

Comments (7)

34r7h avatar 34r7h commented on July 30, 2024

Notice the first image has a native asset with quantity of only 1 , whereas the second image is a ss from cardano showing 2.

Screen Shot 2022-07-06 at 23 11 32

Screen Shot 2022-07-06 at 23 10 56

It's worth noting that my front-end is also pulling from blockfrost (via nodejs) and showing the correct amount..
Screen Shot 2022-07-06 at 23 20 39

from pycardano.

Et9797 avatar Et9797 commented on July 30, 2024

What seems to be the issue here? As far as I can tell there's two UTxOs, each have the Xymbol token with a quantity of 1. So a total of 2 for the address, as shown on Cardanoscan. What I think you're doing on the front-end is querying Blockfrost's asset addresses endpoint assets/{asset}/addresses, however in Pycardano you're querying utxos, so you'll need to sum them up

from pycardano.

mmahut avatar mmahut commented on July 30, 2024

@34r7h please read a little bit about how the UTXO model works. The data reported are correct.

from pycardano.

34r7h avatar 34r7h commented on July 30, 2024

@Et9797 you're right, my mistake. Been a long struggle to get systems working and twice before BF data wasn't updating so I jumped to an incorrect conclusion. Thanks for helping me see.

from pycardano.

34r7h avatar 34r7h commented on July 30, 2024

@Et9797 i get two utxos from the same tx id when the utxo is a minting tx. difficult to build a change function. can you recommend a good way to handle this scenario:

─────────────────────────
utxos_from_bf: <class 'list'>
───────────────

0: {'input': {'index': 0,
 'transaction_id': TransactionId(hex='12a3c696904332e678dc4897b343e111dd688caa9e567e24255aa3a8bd84c754')},
 'output': {'address': addr1q9nzv2662ey4kkx96makz82q99wwzehs2uzrt9wwyttq723xkkkcpe0xgfzya3g0jzz825fyfzwm7melppsjr3uw72qs7am8ys,
 'amount': {'coin': 1379280,
 'multi_asset': {ScriptHash(hex='ef86d15fdc26f796f22582bdafa4369d13e8cd47ef0480b6f57dc899'): {AssetName(b'Panjtara Token'): 1}}},
 'datum_hash': None}} 

1: {'input': {'index': 1,
 'transaction_id': TransactionId(hex='12a3c696904332e678dc4897b343e111dd688caa9e567e24255aa3a8bd84c754')},
 'output': {'address': addr1q9nzv2662ey4kkx96makz82q99wwzehs2uzrt9wwyttq723xkkkcpe0xgfzya3g0jzz825fyfzwm7melppsjr3uw72qs7am8ys,
 'amount': {'coin': 2428467, 'multi_asset': {}},
 'datum_hash': None}} 

from pycardano.

Et9797 avatar Et9797 commented on July 30, 2024

@Et9797 i get two utxos from the same tx id when the utxo is a minting tx. difficult to build a change function. can you recommend a good way to handle this scenario:

─────────────────────────
utxos_from_bf: <class 'list'>
───────────────

0: {'input': {'index': 0,
 'transaction_id': TransactionId(hex='12a3c696904332e678dc4897b343e111dd688caa9e567e24255aa3a8bd84c754')},
 'output': {'address': addr1q9nzv2662ey4kkx96makz82q99wwzehs2uzrt9wwyttq723xkkkcpe0xgfzya3g0jzz825fyfzwm7melppsjr3uw72qs7am8ys,
 'amount': {'coin': 1379280,
 'multi_asset': {ScriptHash(hex='ef86d15fdc26f796f22582bdafa4369d13e8cd47ef0480b6f57dc899'): {AssetName(b'Panjtara Token'): 1}}},
 'datum_hash': None}} 

1: {'input': {'index': 1,
 'transaction_id': TransactionId(hex='12a3c696904332e678dc4897b343e111dd688caa9e567e24255aa3a8bd84c754')},
 'output': {'address': addr1q9nzv2662ey4kkx96makz82q99wwzehs2uzrt9wwyttq723xkkkcpe0xgfzya3g0jzz825fyfzwm7melppsjr3uw72qs7am8ys,
 'amount': {'coin': 2428467, 'multi_asset': {}},
 'datum_hash': None}} 

Not exactly sure what you're after. If you're just trying to get the balance of an address you can simply use the api function from Pycardano's Blockfrost chain context like so:

from pycardano import *

NETWORK = Network.TESTNET
chain_context = BlockFrostChainContext(
    project_id="API_KEY_HERE",
    network=NETWORK
)

nami_address = Address.from_primitive("YOUR_ADDR")

balance = chain_context.api.address(str(nami_address))
print(balance)

Now parse the tokens/ADA from the returned Namespace object. Note: the ADA amount is including collateral + Ada locked with assets. So don't be confused if Nami shows a slightly lower amount than that (provided you're using Nami).

from pycardano.

34r7h avatar 34r7h commented on July 30, 2024

Cheers, @Et9797

I'm not using Nami, I'm building a wallet interface in my project. Lot's of things work until edge cases come up, such as the token retainers and returns not meeting minimum requirements. It's difficult to reason about this considering there's not much of a difference between a minting transaction and another utxo when balancing inputs and outputs.

Is there a way besides checking via blockfrost.BlockFrostApi.asset(asset_policy) if a utxo is a minting utxo containing unspendable ada? I think really this is a problem cardano should address at it's core else I would think many developers will be addressing the same issue continuously.

from pycardano.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.