Skip to main content

credential_id

Function credential_id 

Source
pub fn credential_id(
    subject: &AccountID,
    issuer: &AccountID,
    credential_type: &[u8],
) -> Result<LedgerEntryIdBytes>
Expand description

Generates a credential ledger entry ID for a given subject, issuer, and credential type.

A credential ledger entry ID is used to reference credential entries in the XRP Ledger.

§Arguments

  • subject - The AccountID of the subject for whom the credential is issued
  • issuer - The AccountID of the entity issuing the credential
  • credential_type - A byte slice representing the type of credential

§Returns

  • Result<LedgerEntryIdBytes> - On success, returns a 32-byte credential ledger entry ID. On failure, returns an Error with the corresponding error code.

§Safety

This function makes unsafe FFI calls to the host environment through the host::credential_id function.

§Example

use xrpl_common_stdlib::types::account_id::AccountID;
use xrpl_common_stdlib::ledger_entry_ids::credential_id;
use xrpl_common_stdlib::host::trace::{ trace_hex, trace_num };
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let subject: AccountID =
        AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
    let issuer: AccountID =
        AccountID::from(*b"\xd5\xb9\x84VP\x9f \xb5'\x9d\x1eJ.\xe8\xb2\xaa\x82\xaec\xe3");
    let cred_type: &[u8] = b"termsandconditions";
    match credential_id(&subject, &issuer, cred_type) {
      xrpl_common_stdlib::host::Result::Ok(id) => {
        trace_hex("Generated ledger entry ID", &id);
      }
      xrpl_common_stdlib::host::Result::Err(e) => {
        trace_num("Error assembling ledger entry ID", e.code() as i64);
      }
    }
    Ok(())
}