Payment Integration

Guide for integrating blockchain payments with NCN Network.


Overview

NCN Network uses blockchain-based payments:

  1. Client receives payment info after submitting request

  2. Client pays to smart contract

  3. Client confirms payment with gateway

  4. Inference proceeds

  5. Payment distributed on completion


Payment Flow

┌──────────────────────────────────────────────────────────────────────────┐
│                          Payment Flow                                     │
│                                                                          │
│   Client                 Gateway              Blockchain                 │
│     │                       │                      │                     │
│     │ 1. Submit request     │                      │                     │
│     │──────────────────────▶│                      │                     │
│     │                       │                      │                     │
│     │ 2. Payment info       │                      │                     │
│     │◀──────────────────────│                      │                     │
│     │   (amount, contract)  │                      │                     │
│     │                       │                      │                     │
│     │ 3. Pay to contract    │                      │                     │
│     │───────────────────────────────────────────────▶│                    │
│     │                       │                      │                     │
│     │ 4. tx_hash            │                      │                     │
│     │◀──────────────────────────────────────────────│                    │
│     │                       │                      │                     │
│     │ 5. Confirm payment    │                      │                     │
│     │──────────────────────▶│                      │                     │
│     │   (tx_hash)           │                      │                     │
│     │                       │                      │                     │
│     │                       │ 6. Verify tx         │                     │
│     │                       │──────────────────────▶│                    │
│     │                       │                      │                     │
│     │ 7. Processing...      │                      │                     │
│     │◀──────────────────────│                      │                     │
│     │                       │                      │                     │
│     │ 8. Result             │                      │                     │
│     │◀──────────────────────│                      │                     │
│     │                       │                      │                     │
└──────────────────────────────────────────────────────────────────────────┘

Prerequisites

  • Web3 wallet (MetaMask, etc.) or programmatic wallet

  • NCN tokens (testnet: use faucet)

  • ETH for gas fees


Contract Addresses

Testnet (Forknet)

Contract
Address

InferencePayment

0x4361115359E5C0a25c9b2f8Bb71184F010b768ea

NCNToken

0x38E2565e8905BeAf83C34b266592465C22A2f108

Network Config:

  • RPC URL: https://testnet-rpc-1.forknet.io

  • Chain ID: 828


Integration Steps

1. Submit Request & Get Payment Info

2. Approve Token Spend

3. Initiate Payment

4. Confirm Payment with Gateway

5. Wait for Result


JavaScript Integration

Using ethers.js


Complete Example

Python with Full Payment Flow


Testnet Faucet

Get testnet NCN tokens:


Next Steps

Last updated