{
  "name": "Create autonomous payment agents using AgentGatePay and multi-chain tokens",
  "nodes": [
    {
      "id": "92e66d1d-f0f5-4d1e-96cd-aec1f1916e7d",
      "name": "▶️ START",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        608,
        336
      ]
    },
    {
      "id": "5d3971b4-3854-40d0-b967-51c245a8dec1",
      "name": "1️⃣ Load Config",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        336
      ]
    },
    {
      "id": "f9512e04-334e-4d81-9e99-90c3d89c9a3f",
      "name": "2️⃣ 📊 Get Mandate Token",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        1024,
        336
      ]
    },
    {
      "id": "64fe4d58-91f7-41fd-a5a0-87ec24b44e6d",
      "name": "2B️⃣ Normalize Result",
      "type": "n8n-nodes-base.code",
      "position": [
        1232,
        336
      ]
    },
    {
      "id": "2b833bcc-d396-4680-b313-0a1d4941cb74",
      "name": "3️⃣ Has Token?",
      "type": "n8n-nodes-base.if",
      "position": [
        1440,
        336
      ]
    },
    {
      "id": "09934b2c-4f43-4d94-9952-93f22fd20353",
      "name": "4️⃣ ✅ Verify Existing Token",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1696,
        192
      ]
    },
    {
      "id": "9e9e0ede-81f8-472b-9364-5069045cfbf3",
      "name": "4B️⃣ Check Verification",
      "type": "n8n-nodes-base.code",
      "position": [
        1904,
        192
      ]
    },
    {
      "id": "075f1847-da02-4a80-907a-0c978ea1d619",
      "name": "5️⃣ 🆕 Create New Mandate",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1696,
        480
      ]
    },
    {
      "id": "8ae0aef5-0581-45f9-8aed-ee291f01fe6c",
      "name": "5B️⃣ Parse New Mandate",
      "type": "n8n-nodes-base.code",
      "position": [
        1904,
        480
      ]
    },
    {
      "id": "c698bfa3-31df-4d15-b853-fbae8b6dc95f",
      "name": "6️⃣ ✅ Verify New Mandate",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2112,
        480
      ]
    },
    {
      "id": "e6648b7b-da08-4471-a8c9-d3022cb6dae5",
      "name": "6B️⃣ Check New Mandate",
      "type": "n8n-nodes-base.code",
      "position": [
        2320,
        480
      ]
    },
    {
      "id": "18397ef6-45a5-49ba-9f8a-af2af960f664",
      "name": "7️⃣ 💾 Insert Token",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        2528,
        480
      ]
    },
    {
      "id": "ce95fef9-8a7c-44d4-a56f-80d2b8a2054c",
      "name": "7B️⃣ Restore Data",
      "type": "n8n-nodes-base.code",
      "position": [
        2720,
        480
      ]
    },
    {
      "id": "98ce0832-7986-4700-9731-eebdf91742bd",
      "name": "8️⃣ 🔀 Merge Paths",
      "type": "n8n-nodes-base.code",
      "position": [
        2112,
        192
      ]
    },
    {
      "id": "8d0a44b0-efe9-48ed-9e92-3c08f8741e35",
      "name": "9️⃣ Request Resource (x402)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2320,
        192
      ]
    },
    {
      "id": "187810bc-9ee3-4fdb-8577-338dd8e45d01",
      "name": "9B️⃣ Parse 402 Response",
      "type": "n8n-nodes-base.code",
      "position": [
        2528,
        192
      ]
    },
    {
      "id": "d75a575f-995e-4dca-82b3-c48e7b095257",
      "name": "🔟 🔒 Sign Payment (Render)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2720,
        192
      ]
    },
    {
      "id": "2eab8b07-a05e-4391-9ec1-2b5c3a1c9697",
      "name": "1️⃣1️⃣ Extract TX Hashes",
      "type": "n8n-nodes-base.code",
      "position": [
        2928,
        192
      ]
    },
    {
      "id": "1aad75be-ca5b-447a-8b5f-6907b369ecde",
      "name": "1️⃣2️⃣ Submit Payment (MCP)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3136,
        192
      ]
    },
    {
      "id": "7a2ff1f9-bf4a-425a-ba93-125ec6c95ed3",
      "name": "1️⃣3️⃣ Receive Resource",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3344,
        192
      ]
    },
    {
      "id": "cec5d7b2-90e4-4d84-81cc-cf4d6f33a308",
      "name": "1️⃣4️⃣ Complete Task",
      "type": "n8n-nodes-base.code",
      "position": [
        3552,
        192
      ]
    },
    {
      "id": "77711363-6bea-4837-8ee9-aa49bbe04633",
      "name": "START HERE",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 520,
        "height": 600,
        "content": "# Buyer Agent Workflow\n\n**What it does:** AI agent that buys resources from sellers using AgentGatePay. Automatically reuses mandate tokens to track spending.\n\n**Quick setup (2 min):**\n1. Create Data "
      }
    },
    {
      "id": "49fe3a6c-4c97-4c7a-b5a4-764da49d2866",
      "name": "Sticky Note 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        224
      ],
      "parameters": {
        "width": 880,
        "height": 280,
        "content": "## Mandate Management\n\nLoads your config, checks if you have an existing mandate token in the Data Table. If found, verify it. If not, create a new one."
      }
    },
    {
      "id": "3c1b7cc0-e7ab-466e-abf8-71b752011527",
      "name": "Sticky Note 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        64
      ],
      "parameters": {
        "width": 418,
        "height": 280,
        "content": "## Token Verification\n\nAsks AgentGatePay if your existing token is still valid. Checks signature, expiry, and remaining budget. If expired, you'll get clear instructions to renew."
      }
    },
    {
      "id": "f42cea23-beb7-4fd2-8a63-b90ed0e7adb6",
      "name": "Sticky Note 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1632,
        384
      ],
      "parameters": {
        "width": 1228,
        "height": 280,
        "content": "## New Mandate Creation\n\nCreates fresh mandate via Gateway API, verifies it works, validates the token format, then saves to Data Table. Only runs when you don't have a valid token."
      }
    },
    {
      "id": "368ec38d-61d3-4a32-aab6-f1fe07d7aa2e",
      "name": "Sticky Note 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2080,
        64
      ],
      "parameters": {
        "width": 952,
        "height": 280,
        "content": "## Payment Flow\n\nMerges both paths (reused or new token), requests the resource, receives 402 payment details, signs the payment via Render service, extracts transaction hashes."
      }
    },
    {
      "id": "d0ca8152-ff18-4414-b214-72c47dad9d19",
      "name": "Sticky Note 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3072,
        64
      ],
      "parameters": {
        "width": 648,
        "height": 280,
        "content": "## Resource Delivery\n\nSubmits payment proof to Gateway, receives the paid resource from seller, calculates updated budget, and completes the task with full summary."
      }
    }
  ],
  "connections": {
    "▶️ START": {
      "main": [
        [
          {
            "node": "1️⃣ Load Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3️⃣ Has Token?": {
      "main": [
        [
          {
            "node": "4️⃣ ✅ Verify Existing Token",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5️⃣ 🆕 Create New Mandate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1️⃣ Load Config": {
      "main": [
        [
          {
            "node": "2️⃣ 📊 Get Mandate Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7B️⃣ Restore Data": {
      "main": [
        [
          {
            "node": "8️⃣ 🔀 Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8️⃣ 🔀 Merge Paths": {
      "main": [
        [
          {
            "node": "9️⃣ Request Resource (x402)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2B️⃣ Normalize Result": {
      "main": [
        [
          {
            "node": "3️⃣ Has Token?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7️⃣ 💾 Insert Token": {
      "main": [
        [
          {
            "node": "7B️⃣ Restore Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5B️⃣ Parse New Mandate": {
      "main": [
        [
          {
            "node": "6️⃣ ✅ Verify New Mandate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6B️⃣ Check New Mandate": {
      "main": [
        [
          {
            "node": "7️⃣ 💾 Insert Token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4B️⃣ Check Verification": {
      "main": [
        [
          {
            "node": "8️⃣ 🔀 Merge Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9B️⃣ Parse 402 Response": {
      "main": [
        [
          {
            "node": "🔟 🔒 Sign Payment (Render)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2️⃣ 📊 Get Mandate Token": {
      "main": [
        [
          {
            "node": "2B️⃣ Normalize Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6️⃣ ✅ Verify New Mandate": {
      "main": [
        [
          {
            "node": "6B️⃣ Check New Mandate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1️⃣3️⃣ Receive Resource": {
      "main": [
        [
          {
            "node": "1️⃣4️⃣ Complete Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5️⃣ 🆕 Create New Mandate": {
      "main": [
        [
          {
            "node": "5B️⃣ Parse New Mandate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9️⃣ Request Resource (x402)": {
      "main": [
        [
          {
            "node": "9B️⃣ Parse 402 Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔟 🔒 Sign Payment (Render)": {
      "main": [
        [
          {
            "node": "1️⃣1️⃣ Extract TX Hashes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1️⃣1️⃣ Extract TX Hashes": {
      "main": [
        [
          {
            "node": "1️⃣2️⃣ Submit Payment (MCP)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4️⃣ ✅ Verify Existing Token": {
      "main": [
        [
          {
            "node": "4B️⃣ Check Verification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1️⃣2️⃣ Submit Payment (MCP)": {
      "main": [
        [
          {
            "node": "1️⃣3️⃣ Receive Resource",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}