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

Create new method GET_ADAHANDLE #240

Open
mmahut opened this issue Oct 18, 2024 · 0 comments
Open

Create new method GET_ADAHANDLE #240

mmahut opened this issue Oct 18, 2024 · 0 comments
Assignees

Comments

@mmahut
Copy link
Member

mmahut commented Oct 18, 2024

Lace light wallet needs a way to resolve an adahandle, we need therefore implement a new method for doing this, where the handle itself will be passed in param.

The method is very easy, just take how the queries works from their official website.

const handleName = 'web3';
const policyID = 'f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a';

// A blank Handle name should always be ignored.
if (handleName.length === 0) {
  // Handle error.
}

// Convert handleName to hex encoding.
const assetName = Buffer.from(handleName).toString('hex');

// Fetch matching address for the asset.
const data = await fetch(
  `https://cardano-mainnet.blockfrost.io/api/v0/assets/${policyID}${assetName}/addresses`,
  {
    headers: {
      // Your Blockfrost API key
      project_id: process.env.BLOCKFROST_API_KEY,
      'Content-Type': 'application/json'
    }
  }
).then(res => res.json());

if (data?.error) {
  // Handle error.
}

const [{ address }] = data;
console.log(address); // addr1qx3c9...
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

2 participants