Skip to main content

How it works

DrepID standard allow dreps to reserve a name for them. The reserved name can then be used to find out the DRep's id, making it easier to find and delegate to the DRep.

Reserving a name requires following

  • DRep's offchain-signature
  • Platform's signature
  • Small registration fee

Finding out DRepId by name

  • Find out the address that owns the token with that name.
  • Extract DRep-id from the address holding the token

Here's a simple script to demonstrate DRep.ID in action

const libcardano = require("libcardano");
const axios = require("axios");


const handleName = "spannercode";
const drepIdPolicy = "1bc9af6f44cee790f8d4ea19d8628213704cdb0ae54920f1f7715522";

const assetName = Buffer.from(handleName).toString("hex");

// Define your Blockfrost API key
const API_KEY = "mainnetx208KvPkRuilWIH68tPY8PT9v7EbzNe4"; // Replace with your Blockfrost API key
const blockfrostUrl = "https://cardano-mainnet.blockfrost.io";



const getTokenHolders = async (drepIdPolicy, assetName) => {
try {
const apiClient = axios.create({
baseURL: blockfrostUrl,
headers: {
project_id: API_KEY,
},
});

// Fetch matching address for the asset using axios
const response = await apiClient.get(
`/api/v0/assets/${drepIdPolicy}${assetName}/addresses`
);

const data = response.data;

if (data?.error) {
console.error("Error fetching data:", data.error);
return;
}


// extract DRepID and log
const [{ address }] = data;
console.log("Token present At:", address);
const addr = libcardano.ShelleyAddress.fromBech32(address);
const addrStake = addr.stakePart;
const drepCredential = new libcardano.DrepCredential(
addrStake.bytes,
addrStake.isScript
);

console.log("Drep keyHash : " + drepCredential.bytes.toString('hex'));
console.log("Drep Address : " + drepCredential.toBech32());

} catch (error) {
console.log(error)
console.error("Error fetching token holders:", error);
}
};

getTokenHolders(drepIdPolicy,assetName)

Location

483920, Buddhanagar,
Kathmandu 22/2/5, Office 4

Quick Links

DRep ID is a decentralized platform helping
users create unique, URL-friendly identities for
governance and decentralized voting.

© Sireto Technology. All rights reserved.