Andamio Logo
Protocol/Protocol V2/Transaction State Machine/Course

Claim Course Credential

API integration guide for students to claim their course credential NFT after completing all assignments

Claim Course Credential

After all assignment commitments have been accepted by a teacher, the student claims their course credential. This mints a credential NFT to the student's wallet and refunds the enrollment deposit, resulting in a net ADA gain for the student.

Summary

PropertyValue
SystemCourse
RoleStudent
Type Keycredential_claim
Build EndpointPOST /api/v2/tx/course/student/credential/claim
DB SyncNo
Service Fee0 ADA
Est. Wallet Cost~-1.03 ADA

The estimated wallet cost is negative, meaning the student gains ADA. The breakdown: transaction fee ~0.35 ADA minus deposit refund ~1.38 ADA. The student recovers the enrollment deposit they paid when they first committed to an assignment.

Build Transaction

Endpoint

POST /api/v2/tx/course/student/credential/claim

Request Body

{
  "alias": "student1",
  "courseId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
  "walletData": {
    "usedAddresses": ["addr1qx2fxv..."],
    "changeAddress": "addr1qx2fxv..."
  }
}
FieldTypeRequiredDescription
aliasstring (Alias)YesThe student's access token alias.
courseIdstring (GYMintingPolicyId)YesThe 56-character hex course policy ID.
walletDataWalletDataNoObject containing usedAddresses (string[]) and changeAddress (string).

Response

{
  "unsignedTxCBOR": "84a800..."
}

The response contains the unsigned transaction CBOR, ready for the user's wallet to sign. Upon confirmation, the credential NFT is minted directly to the student's wallet.

Register Transaction

After the user signs and submits the transaction, register it with the state machine:

POST /api/v2/tx/register

{
  "tx_hash": "64-char hex hash from wallet.submitTx()",
  "tx_type": "credential_claim"
}

No metadata is required. The credential NFT lives entirely on-chain in the student's wallet — the blockchain is the sole source of truth for credential ownership.

No specific off-chain endpoints are associated with credential claims. The credential NFT in the student's wallet serves as the verifiable proof of course completion. Standard Cardano tooling can be used to verify the credential's existence and authenticity by checking the course policy ID.

Example: Full Lifecycle

const API_URL = "https://api.andamio.io";

// 1. Build
const buildRes = await fetch(`${API_URL}/api/v2/tx/course/student/credential/claim`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": API_KEY,
    "Authorization": `Bearer ${userJwt}`,
  },
  body: JSON.stringify({
    alias: "student1",
    courseId: "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
    walletData: {
      usedAddresses: [walletAddress],
      changeAddress: walletAddress,
    },
  }),
});
const { unsignedTxCBOR } = await buildRes.json();

// 2. Sign
const signedTx = await wallet.signTx(unsignedTxCBOR);

// 3. Submit
const txHash = await wallet.submitTx(signedTx);

// 4. Register
await fetch(`${API_URL}/api/v2/tx/register`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": API_KEY,
    "Authorization": `Bearer ${userJwt}`,
  },
  body: JSON.stringify({
    tx_hash: txHash,
    tx_type: "credential_claim",
  }),
});

// 5. Monitor (SSE)
const events = new EventSource(
  `${API_URL}/api/v2/tx/stream/${txHash}`
);
events.addEventListener("state_change", (e) => {
  const data = JSON.parse(e.data);
  console.log(`State: ${data.old_state} → ${data.new_state}`);
});
events.addEventListener("complete", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Final: ${data.final_state}`);
  events.close();
});

See Also