Fund Treasury
API integration guide for adding funds to a project treasury
Fund Treasury
Funding the treasury allows any user to deposit ADA or native assets into a project's on-chain treasury. The treasury holds funds used to pay task rewards when contributors complete work. Any user can fund a treasury — no specific role is required beyond having a wallet.
Summary
| Property | Value |
|---|---|
| System | Project |
| Role | User (any) |
| Type Key | treasury_fund |
| Build Endpoint | POST /api/v2/tx/project/user/treasury/add-funds |
| DB Sync | No |
| Service Fee | 0 ADA |
| Est. Wallet Cost | tx fee + deposit amount |
The wallet cost is the transaction fee (typically under 0.5 ADA) plus the full deposit amount. The treasury balance is tracked entirely on-chain with no database sync.
Build Transaction
Endpoint
POST /api/v2/tx/project/user/treasury/add-funds
Request Body
{
"project_id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"deposit_value": [["lovelace", 500000000]],
"alias": "funder1",
"initiator_data": {
"usedAddresses": ["addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"],
"changeAddress": "addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x"
}
}| Field | Type | Required | Description |
|---|---|---|---|
project_id | string (GYMintingPolicyId) | Yes | 56-character hex policy ID returned from project creation. |
deposit_value | array | Yes | Asset class/quantity pairs as [[unit, amount]]. For ADA, use ["lovelace", amount] where amount is in lovelace (1 ADA = 1,000,000 lovelace). |
alias | string (Alias) | No | The funder's access token alias, if they have one. |
initiator_data | WalletData | No | Object containing usedAddresses (string[]) and changeAddress (string). If omitted, the Gateway resolves wallet data from the authenticated session. |
Response
{
"unsigned_tx": "84a800..."
}The response contains the unsigned transaction CBOR, ready for the user's wallet to sign.
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": "treasury_fund"
}No metadata is required. Since the treasury balance is tracked on-chain only, the state machine confirms the transaction but does not update the database with balance information.
Related API Endpoints
| Endpoint | Description |
|---|---|
GET /api/v2/projects/{project_id}/treasury | Fetch the current treasury balance and funding history |
Example: Full Lifecycle
const API_URL = "https://api.andamio.io";
// 1. Build
const buildRes = await fetch(`${API_URL}/api/v2/tx/project/user/treasury/add-funds`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
project_id: projectId,
deposit_value: [["lovelace", 500000000]],
alias: "funder1",
initiator_data: {
usedAddresses: [walletAddress],
changeAddress: walletAddress,
},
}),
});
const { unsigned_tx } = await buildRes.json();
// 2. Sign
const signedTx = await wallet.signTx(unsigned_tx);
// 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: "treasury_fund",
}),
});
// 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
- Owner: Create Project -- Initial treasury deposit at creation
- Manager: Manage Tasks -- Tasks funded by the treasury