We are developing an app that must get the asset id and get its details from metadata, right now we are using blockfrost.io. It works very good for policy Id's, we can use the pool.pm website and get the information regarding all the assets the policy has.

Unfortunately, it doesn't work very well for the asset id... The blockfrost only accepts the concatenation of policy id and the hex encoded asset name. I can't determine the hex encoded asset name. If any of you know how to do that let me know. Thanks in advance.

this is the endpoint: https://cardano-mainnet.blockfrost.io/api/v0/assets/{asset}

some valid id's I found using postman: 0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04756e7369673236383531

  • Meta comment. Why would you use a centralized, single point of failure component in a service whose main goal is to create decentralized ecosystem? So, instead of calling blockchain wrapped with web api you should be querying the blockchain yourself. Web api for blockchain does not make much sense.
    – matcheek
    Jun 22 at 10:40
  • @matcheek makes a lot of sense, I don't have the resources to build an API like this for my project, I can focus on whatever my project needs and use their api. this is industry standard development. The JSON web api is used in several types of frameworks and libraries, do I need to create everything from scratch just for purism and never delivers my app? That doesnt make sense, if the point of failure happens we can fix the app but never develop anything with premature optimizations its amateurism approach. Jun 23 at 11:48

Let's take this asset as an example: https://pool.pm/0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04.unsig26071

  • Policy ID: 0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04
  • Asset name: unsig26071

To request this asset from the blockfrost.io API, you have to convert the name to HEX and then concatenate them (without a . in between).

How you do this depends on the programming language you use. You need to find a way to convert a string to its HEX representation.

Here's an example in C#:

using System;
using System.Text;

string assetName = "unsig26071";
byte[] bytes = Encoding.UTF8.GetBytes(assetName);
string hexAssetName = Convert.ToHexString(bytes); // 756e7369673236303731

To verify that you convert the names correctly, you can use a page like this one: http://string-functions.com/string-hex.aspx

Here's the converted example on cardanoscan: https://cardanoscan.io/token/0e14267a8020229adc0184dd25fa3174c3f7d6caadcb4425c70e7c04.756e7369673236303731

Your blockfrost.io request would look like this:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.