CreditsClient
Namespace: Daisi.Protos.V1
Inheritance: CreditsProto.CreditsProtoClient
The Credits service manages the credit economy within the DAISI network. Hosts earn credits by processing inference tokens and maintaining uptime.
Consumers spend credits when using hosts for inference. Administrators can set earn multipliers, purchase credits, and make manual adjustments.
Setup
The Credits service is accessed via the gRPC-generated CreditsProto.CreditsProtoClient. You can create a client using a gRPC channel pointed at the Orc.
using Daisi.Protos.V1; using Grpc.Net.Client; var channel = GrpcChannel.ForAddress(DaisiStaticSettings.OrcUrl); var creditsClient = new CreditsProto.CreditsProtoClient(channel);
Methods
GetCreditAccountResponseGetCreditAccount(GetCreditAccountRequest)
Retrieves the credit account for a given AccountId. Returns balance, totals, and current multipliers.GetCreditTransactionsResponseGetCreditTransactions(GetCreditTransactionsRequest)
Retrieves a paginated list of credit transactions for an account. Each transaction includes the type, amount, running balance, and multiplier applied.SetMultipliersResponseSetMultipliers(SetMultipliersRequest)
Sets the TokenEarnMultiplier and/or UptimeEarnMultiplier on a credit account. Admin only. Pass only the multiplier(s) you want to change.PurchaseCreditsResponsePurchaseCredits(PurchaseCreditsRequest)
Adds purchased credits to an account. Admin only.AdjustCreditsResponseAdjustCredits(AdjustCreditsRequest)
Applies a manual credit adjustment (positive or negative) to an account. Admin only.
Walkthrough: Check an account balance
- Create a
CreditsProto.CreditsProtoClientusing a gRPC channel. - Call
GetCreditAccountwith the target AccountId. - Read the balance and totals from the response.
var request = new GetCreditAccountRequest { AccountId = "acct-123" };
var response = await creditsClient.GetCreditAccountAsync(request);
var account = response.Account;
Console.WriteLine($"Balance: {account.Balance}");
Console.WriteLine($"Total Earned: {account.TotalEarned}");
Console.WriteLine($"Total Spent: {account.TotalSpent}");
Console.WriteLine($"Token Multiplier: {account.TokenEarnMultiplier}x");
Console.WriteLine($"Uptime Multiplier: {account.UptimeEarnMultiplier}x");
Walkthrough: View transaction history
var request = new GetCreditTransactionsRequest
{
AccountId = "acct-123",
PageSize = 20,
PageIndex = 0
};
var response = await creditsClient.GetCreditTransactionsAsync(request);
Console.WriteLine($"Total transactions: {response.TotalCount}");
foreach (var tx in response.Transactions)
{
Console.WriteLine($"[{tx.Type}] {tx.Amount} credits - {tx.Description} (balance: {tx.Balance})");
}
Walkthrough: Set earn multipliers (Admin)
// Set a 1.5x token earn multiplier for an account
var request = new SetMultipliersRequest
{
AccountId = "acct-123",
TokenEarnMultiplier = 1.5
};
var response = await creditsClient.SetMultipliersAsync(request);
Console.WriteLine($"Token Multiplier: {response.Account.TokenEarnMultiplier}x");
Console.WriteLine($"Uptime Multiplier: {response.Account.UptimeEarnMultiplier}x");
Credit Transaction Types
- TokenEarning - Credits earned by a host for processing inference tokens.
- UptimeEarning - Credits earned by a host for maintaining uptime. A flat hourly rate plus uptime bonus tiers (Bronze 1.1x, Silver 1.2x, Gold 1.5x).
- InferenceSpend - Credits spent by a consumer when using a host for inference.
- Purchase - Credits added to an account via a purchase.
- AdminAdjustment - Manual credit adjustment by an administrator.
Uptime Bonus Tiers
Hosts earn a multiplier on their token earnings based on their rolling 30-day uptime percentage:
- None - Below 90% uptime: 1.0x multiplier
- Bronze - 90% or higher: 1.1x multiplier
- Silver - 95% or higher: 1.2x multiplier
- Gold - 99% or higher: 1.5x multiplier