
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
@aigentic/economy-wasm
Advanced tools
CRDT-based autonomous credit economy for distributed compute networks - WASM optimized
A CRDT-based autonomous credit economy for distributed compute networks. Provides conflict-free P2P credit tracking, stake/slash mechanics, and reputation scoring - a blockchain alternative for edge computing and AI agent coordination.
npm install ruvector-economy-wasm
# or
yarn add ruvector-economy-wasm
# or
pnpm add ruvector-economy-wasm
import init, {
CreditLedger,
ReputationScore,
StakeManager,
contribution_multiplier,
SlashReason
} from 'ruvector-economy-wasm';
// Initialize WASM module
await init();
// Create a credit ledger for a node
const ledger = new CreditLedger("node-123");
// Earn credits for completed tasks
ledger.credit(100n, "task:compute-job-456");
console.log(`Balance: ${ledger.balance()}`);
// Check early adopter multiplier
const mult = contribution_multiplier(50000.0); // 50K network compute hours
console.log(`Multiplier: ${mult.toFixed(2)}x`); // ~8.5x for early adopters
// Credit with multiplier applied
ledger.creditWithMultiplier(50n, "task:bonus-789");
// Track reputation
const rep = new ReputationScore(0.95, 0.98, 1000n);
console.log(`Composite score: ${rep.compositeScore()}`);
console.log(`Tier: ${rep.tierName()}`);
Conflict-free Replicated Data Types (CRDTs) enable distributed systems to:
This package uses:
// P2P merge example - works regardless of message order
const nodeA = new CreditLedger("node-A");
const nodeB = new CreditLedger("node-B");
// Both nodes earn credits independently
nodeA.credit(100n, "job-1");
nodeB.credit(50n, "job-2");
// Export for P2P sync
const earnedA = nodeA.exportEarned();
const spentA = nodeA.exportSpent();
// Merge on node B - associative, commutative, idempotent
const merged = nodeB.merge(earnedA, spentA);
console.log(`Merged ${merged} updates`);
Early network contributors receive higher rewards that decay as the network matures:
Multiplier = 1 + 9 * exp(-compute_hours / 100,000)
Network Hours | Multiplier
---------------|------------
0 | 10.0x (Genesis)
10,000 | ~9.0x
50,000 | ~6.0x
100,000 | ~4.3x
200,000 | ~2.2x
500,000 | ~1.0x (Baseline)
import { contribution_multiplier, get_tier_name, get_tiers_json } from 'ruvector-economy-wasm';
// Check current multiplier
const hours = 25000;
const mult = contribution_multiplier(hours);
console.log(`At ${hours} hours: ${mult.toFixed(2)}x multiplier`);
// Get tier name
const tier = get_tier_name(hours); // "Pioneer"
// Get all tier definitions
const tiers = JSON.parse(get_tiers_json());
import { StakeManager, SlashReason } from 'ruvector-economy-wasm';
const stakeManager = new StakeManager();
// Stake credits for network participation
stakeManager.stake("node-123", 1000n);
console.log(`Staked: ${stakeManager.getStake("node-123")}`);
// Check if node meets minimum stake
if (stakeManager.meetsMinimum("node-123")) {
console.log("Node can participate");
}
// Delegate stake to another node
stakeManager.delegate("node-123", "validator-1", 500n);
console.log(`Effective stake: ${stakeManager.getEffectiveStake("validator-1")}`);
// Slash for bad behavior
const slashedAmount = stakeManager.slash(
"bad-actor",
SlashReason.DoubleSpend,
"Evidence: duplicate transaction IDs"
);
console.log(`Slashed ${slashedAmount} credits`);
| Reason | Severity | Description |
|---|---|---|
InvalidResult | Medium | Submitted incorrect computation results |
DoubleSpend | High | Attempted to spend same credits twice |
SybilAttack | Critical | Multiple fake identities detected |
Downtime | Low | Excessive offline periods |
Spam | Medium | Flooding the network |
Malicious | Critical | Intentional harmful behavior |
import { ReputationScore, composite_reputation } from 'ruvector-economy-wasm';
// Create reputation with tracking
const rep = ReputationScore.newWithTracking(
950n, // tasks completed
50n, // tasks failed
BigInt(30 * 24 * 3600), // uptime seconds
BigInt(31 * 24 * 3600), // total seconds
5000n // stake amount
);
// Record task outcomes
rep.recordSuccess();
rep.recordFailure();
// Calculate composite score
// Formula: accuracy^2 * uptime * stake_weight
const score = rep.compositeScore();
console.log(`Composite: ${(score * 100).toFixed(1)}%`);
// Get tier
console.log(`Tier: ${rep.tierName()}`); // "Elite", "Trusted", "Standard", etc.
// Check participation eligibility
if (rep.meetsMinimum(0.9, 0.95, 100n)) {
console.log("Eligible for premium tasks");
}
// Compare reputations
const rep2 = new ReputationScore(0.92, 0.96, 3000n);
console.log(`Better reputation: ${rep.isBetterThan(rep2) ? 'rep1' : 'rep2'}`);
| Tier | Score Range | Benefits |
|---|---|---|
| Elite | >= 0.95 | Priority task assignment, lowest fees |
| Trusted | >= 0.85 | High-value tasks, reduced collateral |
| Standard | >= 0.70 | Normal participation |
| Probation | >= 0.50 | Limited task types |
| Restricted | < 0.50 | Basic tasks only, increased monitoring |
const ledger = new CreditLedger("node-123");
ledger.credit(100n, "job-1");
ledger.credit(200n, "job-2");
// Get state root for verification
const stateRoot = ledger.stateRoot();
const stateRootHex = ledger.stateRootHex();
console.log(`State root: ${stateRootHex}`);
// Verify state integrity
const isValid = ledger.verifyStateRoot(expectedRoot);
| Method | Description |
|---|---|
new(node_id) | Create ledger for node |
credit(amount, reason) | Earn credits |
creditWithMultiplier(base_amount, reason) | Earn with network multiplier |
deduct(amount) | Spend credits |
refund(event_id, amount) | Refund a deduction |
balance() | Get available balance |
stake(amount) | Lock credits for participation |
slash(amount) | Penalty for bad behavior |
merge(other_earned, other_spent) | CRDT merge operation |
exportEarned() / exportSpent() | Export for P2P sync |
stateRoot() / stateRootHex() | Merkle verification |
| Method | Description |
|---|---|
new(accuracy, uptime, stake) | Create with scores |
newWithTracking(...) | Create with detailed tracking |
compositeScore() | Calculate composite (0.0-1.0) |
tierName() | Get reputation tier |
recordSuccess() / recordFailure() | Track task outcomes |
stakeWeight() | Logarithmic stake weight |
meetsMinimum(accuracy, uptime, stake) | Check eligibility |
| Method | Description |
|---|---|
new() | Create manager |
stake(node_id, amount) | Stake credits |
unstake(node_id, amount) | Unstake (if unlocked) |
delegate(from, to, amount) | Delegate to another node |
slash(node_id, reason, evidence) | Slash for violation |
getEffectiveStake(node_id) | Own + delegated stake |
meetsMinimum(node_id) | Check stake requirement |
MIT
Keywords: CRDT, distributed systems, credits, P2P, peer-to-peer, blockchain alternative, reputation, stake, slash, economy, WebAssembly, WASM, edge computing, decentralized, conflict-free, eventual consistency, G-Counter, PN-Counter
FAQs
CRDT-based autonomous credit economy for distributed compute networks - WASM optimized
We found that @aigentic/economy-wasm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.