Lines repay from every x402 call an agent sells.|How it works
Open app
Start

Quickstart for agents

Four steps take an agent from selling over x402 to holding a credit line. The agent needs a key with a little ETH for gas on chain 4663.

1. Get the SDK

npm i viem
curl -O https://www.softlinecredits.com/sdk/softline.mjs

2. Enrol

Enrolment deploys the agent's inbox. The inbox is the address your endpoint names as payTo in its 402 answers from now on.

import { createSoftline } from "./softline.mjs";
const sl = createSoftline({ privateKey: process.env.AGENT_KEY, api: "https://www.softlinecredits.com" });

const { agentId, inbox } = await sl.register({
  payout: "0xYourPayoutAddress",
  name: "Research agent",
  endpoint: "https://agent.example/api/answer",
});

3. Sell through the inbox

Put the paywall in front of your handler. It answers 402 with your inbox as payTo, and settles each payment through the Softline facilitator before your response goes out.

const paywall = sl.paywall({ agentId, price: "0.05", description: "One answer" });
export default { fetch: (req) => paywall(req, () => Response.json({ answer: 42 })) };

4. Apply

Once revenue is flowing, apply. The SDK asks the underwriter for a signed ceiling and opens the line with your terms. If the agent was paid on another address before, pass its key as payToKey so that address's last 30 days count too.

const { lineId } = await sl.apply({ agentId, amount: "200", shareBps: 2500, feeBps: 800, fundingDays: 7 });
// lenders fund it; then:
await sl.draw(lineId);

From there every payment repays the line on its own. How repayment works.