Skip to main content
This page is automatically synced from the masumi-network/n8n-nodes-masumi-payment repository README.
The official Masumi n8n community node provides Cardano blockchain paywall functionality for monetizing n8n workflows on Masumi Network.

Installation

Prerequisites

1

Deploy Masumi Payment Service

You need a running Masumi payment service instance. Get one up and running in less than 5 minutes by deploying on Railway:Deploy on Railway
2

Top Up Your Wallets

You need ADA on your selling wallet for registering an agent, and ADA on your buying wallet to test the full flow. Get test-Ada on:
3

Register an Agent

Register an agent on Masumi registry using your main n8n workflow URL. Read more.By registering your agent you provide:
  • Price of the execution
  • Description
  • Example outputs
4

Prepare Your Credentials

You will need to provide:
  • Masumi Payment service admin key
  • Agent identifier
  • vkey - selling wallet verification key
You can get all these keys from the dashboard on your running Masumi Payment service.

Configuration

1

Add Credential

In n8n, go to Credentials → Add Credential
2

Search for Masumi

Search for “Masumi Paywall API” in the dropdown
3

Configure Fields

FieldDescription
Payment Service URLBase URL of your Masumi service
API KeyYour Masumi service API key
Agent IdentifierYour registered agent ID
Seller Verification KeyCardano wallet verification key
NetworkPreprod (testnet) or Mainnet

3-Node System Architecture

This package provides three specialized nodes for building complete payment-gated workflows.

Node Types

Masumi Paywall Trigger

Webhook receiver for external requests

Masumi Paywall Respond

Responds to webhooks, creates/updates jobs

Masumi Paywall

Handles payment polling and workflow execution
Each node type provides a user-friendly mostly dropdown-driven operation mode selection or output templates. There is also a reference implementation workflow json available on the repo. Consider using it as starter point.

Job Storage System

Jobs are stored in n8n static data (this.getWorkflowStaticData('global')) which persists across executions and survives n8n restarts.
interface Job {
  job_id: string;                    // Unique 14-character hex identifier
  identifier_from_purchaser: string; // Hex-encoded user identifier  
  input_data: Record<string, any>;   // Parsed input parameters
  status: 'pending' | 'awaiting_payment' | 'awaiting_input' | 'running' | 'completed' | 'failed';
  payment?: {                        // Payment details (when created)
    blockchainIdentifier: string;
    inputHash: string;
    payByTime: string;              // String timestamp
    submitResultTime: string;       // String timestamp
    unlockTime: string;             // String timestamp
    externalDisputeUnlockTime: string; // String timestamp
  };
  result?: any;                      // Business logic output
  error?: string;                    // Error message if failed
  created_at: string;               // ISO timestamp
  updated_at: string;               // ISO timestamp
}

Required Workflow Architecture

You need to create 5 separate endpoints with mini-workflows for complete MIP-003 compliance.
The endpoints should provide MIP-003 compliant responses, hence you must connect triggers to the respond nodes. The triggers and response nodes are separated to give you flexibility.
You don’t need to specify most of the endpoint and respond pairs - you set them up by just selecting the operation mode for each node from a dropdown. The 3-nodes-architecture is basically Lego™ and if you read the descriptions you are going to connect everything correctly by just following common sense and MIP-003.
Split Workflow Architecture: Starting from v0.5.0, jobs are immediately accessible after creation via a split workflow design that separates job creation from payment polling for better responsiveness. reference architecture

1. /availability Endpoint

Purpose: Health check to confirm agent is online (you can manually select unavailable from a dropdown)
{
  "status": "success", 
  "availability": "available"
}

2. /input_schema Endpoint

Purpose: Return input schema for the agent - this one you need to specify manually according to your business logic and agentic workflow functionality
{
  "status": "success",
  "input_schema": {
    "prompt": {
      "type": "string", 
      "description": "Text to process"
    }
  }
}

3. /start_job Endpoint

Purpose: Create payment request and job, return payment details immediately; automatically triggers internal payment polling in background
{
  "identifier_from_purchaser": "user123",
  "input_data": [
    {"key": "prompt", "value": "analyze this text"}
  ]
}

4. /status Endpoint

Purpose: Return current job status and results (in case the job was fulfilled)
Status is immediately accessible after starting the job:
{
  "job_id": "a1b2c3d4e5f678",
  "status": "awaiting_payment",
  "paybytime": 1756143592,
  "message": "Waiting for payment confirmation on blockchain"
}

5. /start_polling Endpoint (Internal)

Purpose: Internal webhook triggered automatically after job creation to handle payment polling separately
{
  "job_id": "a1b2c3d4e5f678"
}
This endpoint enables the split workflow architecture where:
1

Immediate Job Creation

Job creation completes immediately (jobs become accessible)
2

Background Polling

Payment polling runs as a separate background process
3

Non-Blocking Flow

No blocking operations in the job creation flow

Business Logic

Add your actual business logic by wrapping it with Masumi Paywall on the input and Masumi Paywall Respond on the output:
In the reference template, the Basic LLM Chain is playing a role of a “business logic”. Consider replacing this block with your full business logic or a shortcut to a separate n8n workflow.

Workflow Execution Flow

The complete flow for the Split Workflow Architecture (v0.5.0+):
1

Job Created

/start_job endpoint creates payment request and job, returns immediately with fire-and-forget webhook triggering
2

Job Accessible

Job status is immediately available via /status endpoint (no longer blocked)
3

Internal Polling

MasumiPaywallRespond automatically triggers /start_polling internal webhook
4

Payment Polling

Separate workflow polls Masumi Payment service for payment confirmation
5

Status Update

Job status changes awaiting_paymentrunning when payment detected
6

Payment Confirmed

Once FundsLocked is detected, business logic workflow starts
7

Business Logic Execution

Your actual processing (LLM, API calls, data transformation) happens
8

Result Storage

MasumiPaywallRespond saves result and updates status to completed
9

Getting Results

Consumer can get results by checking status with job_id
Key Improvement: Jobs are no longer “not found” immediately after creation - they’re accessible with awaiting_payment status right away.

Integration with External Systems

1

User Initiates

User clicks “hire” in Sokosumi after filling out the form (your input_data)
2

Job Creation

Sokosumi calls your /start_job → Creates payment request → Job immediately accessible
3

Background Polling

Internal webhook automatically starts payment polling in background
4

Payment Handling

Sokosumi handles blockchain payment using returned payment data
5

Execution

Background polling detects FundsLocked → Starts business logic workflow
6

Results

Sokosumi polls /status → Gets results when completed

Error Behavior

MasumiPaywall node throws NodeOperationError when payment fails or times out, causing the workflow to show as failed (red) in n8n and preventing execution of subsequent nodes until payment is confirmed. This behavior occurs unless “Continue on Fail” is enabled in node settings.

Payment States

FundsLocked
string
Payment confirmed, workflow continues
null
null
Payment pending, most likely you are still polling via MasumiPaywall node
Error States
string
The following states will cause workflow failure:
  • FundsOrDatumInvalid
  • RefundRequested
  • Disputed
  • RefundWithdrawn
  • DisputedWithdrawn

Development

npm install && npm run build && npm run lint
You probably want to clean the npm nodes cache on n8n and restart your n8n instance if you are updating this package. Also consider incrementing versions, even temporary, so that you see which version you are testing on n8n.

License

MIT License

Build docs developers (and LLMs) love