Create Course
API integration guide for creating an Andamio course instance on-chain
Create Course
Creating a course is the first step in setting up a learning environment on Andamio. This transaction mints a new course instance on-chain, registering the creator as the owner and first teacher, and returns a unique courseId (policy ID) used for all subsequent course operations.
Summary
| Property | Value |
|---|---|
| System | Course |
| Role | Owner |
| Type Key | course_create |
| Build Endpoint | POST /api/v2/tx/instance/owner/course/create |
| DB Sync | Yes |
| Service Fee | 100 ADA base + 10 ADA per teacher |
| Est. Wallet Cost | ~130 ADA for 1 teacher |
The service fee scales with the number of teachers: 110 ADA for 1 teacher, 120 ADA for 2, and so on. The estimated wallet cost of ~130 ADA for a single teacher breaks down as: transaction fee ~0.53 ADA + service fee 110 ADA + UTxO deposits ~19.15 ADA.
Build Transaction
Endpoint
POST /api/v2/tx/instance/owner/course/create
Request Body
{
"alias": "courseowner",
"teachers": ["courseowner"],
"walletData": {
"usedAddresses": ["addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"],
"changeAddress": "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"
}
}| Field | Type | Required | Description |
|---|---|---|---|
alias | string (Alias) | Yes | The owner's access token alias. Must already have a minted access token. |
teachers | string[] (Alias[]) | Yes | List of teacher aliases to include at creation. The Gateway auto-sets this to [alias] — the creator is always the first teacher. |
walletData | WalletData | No | Object containing usedAddresses (string[]) and changeAddress (string). If omitted, the Gateway resolves wallet data from the authenticated session. |
Response
{
"unsignedTxCBOR": "84a800...",
"courseId": "a1b2c3d4e5f6..."
}The response includes two fields:
unsignedTxCBOR— The unsigned transaction CBOR, ready for the user's wallet to sign.courseId— The on-chain policy ID for the new course. Save this value. It is required as a parameter for every subsequent course operation (managing teachers, managing modules, assessing assignments, etc.).
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": "course_create",
"instance_id": "a1b2c3d4e5f6..."
}The owner_alias is auto-captured from the JWT — no manual metadata is needed. You may optionally include metadata fields for the database record:
| Field | Type | Required | Description |
|---|---|---|---|
title | string | No | Display title for the course |
description | string | No | Course description |
image_url | string | No | URL to a course image or thumbnail |
On confirmation, the state machine registers the course in the database with the owner alias and on-chain courseId.
Related API Endpoints
| Endpoint | Description |
|---|---|
GET /api/v2/courses/{course_id} | Fetch course details after creation, including owner, teachers, and module list |
Example: Full Lifecycle
const API_URL = "https://api.andamio.io";
// 1. Build
const buildRes = await fetch(`${API_URL}/api/v2/tx/instance/owner/course/create`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
alias: "courseowner",
teachers: ["courseowner"],
walletData: {
usedAddresses: [walletAddress],
changeAddress: walletAddress,
},
}),
});
const { unsignedTxCBOR, courseId } = await buildRes.json();
// Save courseId — this is the on-chain policy ID for all subsequent course operations
// 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: "course_create",
instance_id: courseId,
metadata: {
title: "Introduction to Cardano Development",
description: "A hands-on course covering smart contract basics",
},
}),
});
// 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
- Transaction State Machine -- Lifecycle overview
- Cost Estimation -- Fee details
- On-Chain Structure -- CBOR anatomy
- Owner: Manage Teachers -- Add or remove teachers after creation