EconomyFactory deploys a full Backpressure Economics stack in a single transaction. One call creates a StakeManager, CapacityRegistry, BackpressurePool, EscrowBuffer, and PricingCurve, wired together and ready to accept agents. The PIPELINE template also creates a Pipeline contract for multi-stage composition.
Without the factory, deploying an economy requires six separate contract deployments with careful constructor parameter threading. Each contract needs the addresses of others it depends on. The factory handles all of this in one atomic transaction: either everything deploys or nothing does.
After deployment, ownership transfers to your wallet. You control the economy.
Four templates pre-configure the economy for common patterns. The topology is the same (the five core contracts), but stake requirements, escrow limits, and optional components differ.
Independent agents competing for tasks. The default for most AI agent use cases.
import { deployEconomy, Template } from '@puraxyz/sdk/actions/economy'
await deployEconomy(wallet, addrs, {
template: Template.MARKETPLACE,
taskTypeIds: [taskTypeId],
minStake: 100n * 10n ** 18n,
bufferMax: 1000n * 10n ** 18n,
verificationBudgetBps: 0n,
})Agents pooling capacity as a collective. Lower individual stakes, shared escrow.
await deployEconomy(wallet, addrs, {
template: Template.COOPERATIVE,
taskTypeIds: [taskTypeId],
minStake: 25n * 10n ** 18n, // lower barrier
bufferMax: 5000n * 10n ** 18n, // larger shared buffer
verificationBudgetBps: 0n,
})Multi-stage sequential processing. For workflows where output from one agent feeds into the next.
await deployEconomy(wallet, addrs, {
template: Template.PIPELINE,
taskTypeIds: [stage1, stage2, stage3], // one task type per pipeline stage
minStake: 100n * 10n ** 18n,
bufferMax: 2000n * 10n ** 18n,
verificationBudgetBps: 0n,
})Specialized agent groups with quality gates. Higher stakes discourage low-quality providers.
await deployEconomy(wallet, addrs, {
template: Template.GUILD,
taskTypeIds: [taskTypeId],
minStake: 500n * 10n ** 18n, // higher barrier
bufferMax: 500n * 10n ** 18n,
verificationBudgetBps: 0n,
})import { getEconomy, getEconomiesByOwner, economyCount } from '@puraxyz/sdk/actions/economy'
// Get a specific economy by ID
const economy = await getEconomy(publicClient, addrs, economyId)
console.log(economy.stakeManager) // deployed StakeManager address
console.log(economy.capacityRegistry) // deployed CapacityRegistry address
console.log(economy.backpressurePool) // deployed BackpressurePool address
console.log(economy.escrowBuffer) // deployed EscrowBuffer address
console.log(economy.pricingCurve) // deployed PricingCurve address
console.log(economy.pipeline) // zero address if no Pipeline, otherwise deployed
console.log(economy.owner) // your wallet
// List all your economies
const myEconomies = await getEconomiesByOwner(publicClient, addrs, account.address)
// Total economies deployed through the factory
const total = await economyCount(publicClient, addrs)After deploying a base economy, you can layer v2 features on top:
These are separate contracts rather than factory options because they compose freely. A Guild economy with a QualityOracle and VelocityToken is a different product from a Pipeline economy with NestedPool. The factory gives you the base; v2 contracts let you customize.