x402-一种互联网原生支付的开放标准 An open standard for internet-native payments_第1页
x402-一种互联网原生支付的开放标准 An open standard for internet-native payments_第2页
x402-一种互联网原生支付的开放标准 An open standard for internet-native payments_第3页
x402-一种互联网原生支付的开放标准 An open standard for internet-native payments_第4页
x402-一种互联网原生支付的开放标准 An open standard for internet-native payments_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

x402:Anopenstandardforinternet-nativepayments

An

HTTPbasedprotocolforagents

,contextretrieval,APIs,andmore

By:

ErikReppelRonnieCaspersKevinLeffewDannyOrgan

DanKimNemilDalal

CoinbaseDeveloperPlatform

/x402

May6,2025

x402WhitepaperCoinbaseDeveloperPlatform

1

Contents

1Motivation

3

2OnchainPayments:TheFoundationofAutonomousDigitalEconomies

3

2.1WhereTraditionalPaymentRailsFail

3

2.2ScalingPaymentswithBlockchainandDigitalAssets

4

3Howx402Works

4

3.1ExampleIntegration

5

3.2CorePaymentFlow

5

4x402EnablesFrictionlessPayments

5

5CreatingaPaymentLayerforAgenticCommerce

7

5.1EmpoweringAgentstoTransactAutonomously

7

6EnablingNewBusinessModels

8

6.1PragmaticMicropayments

8

6.2SeamlessPay-Per-UseMonetization

8

7SimplifyingPaymentsOperations

8

7.1MitigatingFraud,Chargebacks,andComplianceOverhead

8

7.2Future-Proof,Chain-andToken-AgnosticPayments

9

8Thex402Spec:AFlexibleHTTPStandardforPayments

9

8.1MiddlewareConfiguration

9

8.2HandlingRequestsWithoutPayment

9

9TechnicalSpecifications

10

9.1PaymentRequestFormat

10

9.2PaymentAuthorization

10

9.3TransactionSettlement

10

10IntegrationExamples

11

10.1Server-SideImplementation

11

10.2Client-SideImplementation

11

10.3WalletIntegration

12

10.4TestingandDevelopment

12

11UseCases:RealWorldApplicationsofx402

13

x402WhitepaperCoinbaseDeveloperPlatform

2

12KeyTakeaways

13

13ReferenceImplementation

14

x402WhitepaperCoinbaseDeveloperPlatform

3

Abstract

x402isanopenpaymentstandardthatenablesAIagentsandwebservicestoautonomouslypayforAPIaccess,data,anddigitalservices.Byleveragingthelong-reserved

HTTP402

”PaymentRequired”statuscode,x402eliminatestheneedforAPIkeys,subscriptions,andmanualpaymentprocessing,allowingreal-time,machine-nativetransactionsusingstablecoinslikeUSDC.

Withonelineofcode,developerscanintegratepay-per-usemonetization,unlockingfrictionlesspaymentsforcontextretrievalandthird-partyAPIsforAI-drivenapplications.x402offersinstantsettlement,near-zerofees,andchain-agnosticflexibility,makingittheidealsolutionforAI-firstcommerceandmachine-to-machinepayments.

Motivation

TherapidgrowthofAIandautonomoussystemsisreshapingtheinterneteconomy,butoneofthemajorroadblockstoachievingfullyautonomousAIsystemsisthelackofapaymentsystemthatempowersAIAgentstofunctionwithouthumanintervention.

Legacypaymentsystemsaredesignedprimarilyforhumaninteractions.Assuch,webservicesare:notabletobeusedautonomouslybyAIagents,stuckusinginefficientbusinessmodelslikesubscriptions,andhinderedbyoperationalcomplexitiessuchasdelayedsettlementtimes,hightransactionfees,manualinvoicing,andsusceptibilitytofraudandchargebacks.

ThesechallengescreatesignificantfrictionforAI-drivenapplicationsandmachine-to-machine(M2M)transac-tions,preventingthefullrealizationofautonomousdigitaleconomies.AIagentsrequireinstant,frictionlessaccesstoreal-timecontextualdata,APIservices,anddistributedcomputingresourcestofunctionindepen-dently.Theyneedtheabilitytoexecutemicrotransactionsdynamicallyandautonomously,withoutthehuman-in-the-loopinterventionordelaysassociatedwithlegacypaymentsetups.

BrowserUsageAPIshaveattemptedtoaddresscertainrequirementsofagenticpayments,theycontinuetoleveragesystemsoriginallydesignedforhumanusersratherthanmachines.Consequently,theyremainburdenedbymanualuserexperience(UX)navigation,relianceoncreditcards,accountverificationprocesses,andtheoverallhuman-orientedfrictionthatimpedestrueautomationforagenticinteractions.

Ultimately,themotivationbehindx402istounlockthefullpotentialofautonomousAIsystemsandagenticcommerce,fosteringamoreefficient,frictionless,andscalabledigitaleconomyfortooluse.

Byenablingmachine-nativepayments,x402enablesAIagentstoautonomouslydiscoverandprocurethird-partycloudresources,contextualdata,andAPItools—makingiteasierforthemtoachievetheirtargetedoptimizationgoalswithouthuman-in-the-loopintervention.Thisempowersdevelopers,businesses,andconsumerstoinnovatefreelywithoutpaymentfriction,acceleratingtheadoptionandevolutionofAI-drivencommerce.

OnchainPayments:TheFoundationofAutonomousDigitalEconomies

WhereTraditionalPaymentRailsFail

Legacypaymentsystemsincurhighcosts,slowsettlementtimes,chargebackrisks,andrequirelayersofmanualsetupandauthorizationmakingthemimpracticalforAI-drivencommerce.

Forexample,ACHbanktransferstake1—3daystosettle,whileevencreditcardpayments—despiteinstantauthorization—cantakedaystofinalizeandremainsubjecttoreversalformonths.Additionally,traditional

x402WhitepaperCoinbaseDeveloperPlatform

4

systemspresentsignificantbarrierstofinancialinclusion,leavingapproximately1.4billionpeopleunbankedandwithoutaccess(

source

).

x402bridgesthegap,allowingAIagentsandAPIproviderstointeractseamlesslywithreal-time,trustlesspayments—eliminatingfrictionfromlegacybillingsystemsandunlockingnewpay-per-userevenuemodels.

ScalingPaymentswithBlockchainandDigitalAssets

Comparedtolegacypaymentrails,onchaintransactionsviax402settlein~200ms,providinginstantpaymentfinalityforAPIproviders.Norollingchargebackwindows,nosettlementdelays—justreal-timeaccessandrevenuecollection.Builtonpermissionlessblockchaininfrastructure,x402isavailableworldwidewithoutrequiringcostlyconversionsoraccesstotraditionalfinancialrails.Forabroaderdiscussiononhowonchainpaymentsaretransformingdigitalcommerce

(B,2025)

.

x402eliminatestheseinefficienciesbyleveragingstablecoinsandLayer-2scalingforlow-cost,instant,andautomatedtransactions.Thetablebelowcomparesx402withtraditionalpaymentmethods,demonstratingwhyitisoptimalforAI-first,pay-per-usemodels.

PaymentRail

TypicalFees

SettlementFinality

ChargebackRisk

Scalability

CreditCard

$0.30+2.9%

Days(batch)

Yes,upto120d

65kTPS*

*theoreticalmax

PayPal

~3%+markup

Instant

authorization,

settlementindays

Yes

Unknown

Stripe(PaywithCrypto)

1.5%+

Dependson

blockchain

No-notreversible

Dependson

blockchain

EthereumL1

$1—$5+gas

1—2minforconfirmations

No-notreversible

15—20TPS

x402(onBase)

Free*

*nominalgasi$0.0001

200ms

No-notreversible

Hundredsto

thousandsTPS

Howx402Works

x402isanopenpaymentsprotocoldevelopedbyCoinbasethatenablesAIagentstocompletetransactionsautonomously.Itispoweredbyonchaintechnologyanddigitalcurrencies(primarilystablecoinslikeUSDC)andprovidesalightweight,secure,andinstantaneouspaymentsystemthatwehopecanhelpacceleratetheadoptionofM2Mpaymentsandagenticcommerce.

Thex402protocolutilizesthelong-reserved

HTTP402

”PaymentRequired”statuscodetorequireapaymenttocompleteanAPIrequestorloadawebpage.IfanAPIrequestlackspayment,x402respondswithan

HTTP402PaymentRequiredstatus

,promptingtheclienttopayandretry.

Withthissimpleprotocol,x402removestheneedforAPIkeys,accounts,andsubscriptions.x402enablesanyAPIorcontentprovidertoacceptpay-per-usepaymentsthroughalightweightmiddlewarethatintegratesseamlesslyintoexistinginfrastructures.

x402WhitepaperCoinbaseDeveloperPlatform

5

ExampleIntegration

Withonelineofcode,companiescanmonetizeAPIs,content,andservices:

paymentMiddleware(amount:"0.10",address:"0x...")

CorePaymentFlow

1.ClientRequest—AIagentorapprequestsaccesstoanAPIordigitalresource.

2.PaymentRequired(402)—Ifnovalidpaymentisattached,theserverrespondswith

HTTP402

,providingpricingandpaymentdetails.

3.AgentRetriesRequestwithSignedPayment—Theagentsubmitsasignedpaymentauthorizationaspartoftheretriedrequest.

4.WebServiceVerifies&BroadcastsPayment—Theservervalidatesthepayment,broadcastsit,andreturnsaresponsetotheAPIrequest.

Figure1:x402PaymentFlow:AIAgent艹APIServer艹Blockchain

x402EnablesFrictionlessPayments

x402removesaccountandbillingfrictionfrompayments,enablingtruepay-per-useaccesswithoutsubscrip-tions,prepaidcredits,ormanualinvoicing.Here’showbothAIagentsandhumanscanusex402toaccessdigitalservicesinstantly:

x402WhitepaperCoinbaseDeveloperPlatform

6

Figure2:Comparison:ExistingAgentPaymentProcessvs.x402Pay-Per-UseSimplicity

x402WhitepaperCoinbaseDeveloperPlatform

7

Scenario

TraditionalProcess

Withx402

AIAgents:

AutonomousResearch

Assistant

•Requiresmultipleaccountsubscriptionsforinferenceanddataaccess.

•Designedforhumanstomanually

createanaccount&setupAPIkeys.

•APIwhitelistingorapprovalmayberequiredbeforeuse.

1.AIagentrequestsmarketdataAPI

2.APIrespondswith

HTTP402

PaymentRequiredandcostdetails

3

.AIagentattachesUSDCpaymentandretries

4.InstantAPIaccessgranted,immediatecontextretrieval

HumanUsers:Pay-Per-ArticleNewsAccess

•Requiresaccountsignup&paymentdetails.

•Forcessubscriptionmodel,eveniftheuseronlywantsonearticle.

•Usermustcancelmanuallytoavoidrecurringcharges.

1.Userclickspaywalledarticle

2.

HTTP402PaymentRequiredshows

USDCcost

3.Userconfirmspaymentincryptowallet

4.Articleinstantlyunlocked,nostoredcreditcards

AccessControl

Tofurtherenhancecontentsecurityandaccesscontrolafterpayment,x402canbecombinedwithdecentralizedauthorizationsolutions,enablingcontentproviderstoenforcegranularaccessrules(e.g.,single-useURLs,IP-restrictedcontentstreams)withoutcentralizedauthorizationservers.

CreatingaPaymentLayerforAgenticCommerce

Today’slegacypaymentsystemswerebuiltforhumans—requiringcreditcards,subscriptions,andman-ualinvoicing—makingthemincompatiblewithautonomousAIagents,APIs,andmachine-to-machinetransactions.

AsAIsystemstakeonmoreautomated,decision-makingroles,theyneedapaymentinfrastructurethatisseamlessandfrictionless,enablingautonomousagentstorapidlyaccesscontext,retrievereal-timedata,andexecuteactionsonthird-partysystemswithoutdelayorhumanintervention.

EmpoweringAgentstoTransactAutonomously

AImodelscannowoperateautonomously—butpaymentsremainabottleneck.Withoutamachine-nativesolution,languagemodelsstilllargelydependonhumaninterventiontoaccesscontextandactionsexternaltotheagentmodel.

x402eliminatesthisneedforhumanintervention,providingacrypto-nativepaymentstandardthatallowsAIsystemsto:

•PayperAPIrequest,dataquery,orAImodelinferencewithoutpre-registeringanaccount.

x402WhitepaperCoinbaseDeveloperPlatform

8

•Fetchreal-timeinformationdynamically(e.g.,financialmarketdata,cloudresources).

•Seamlesslyinteractwithonchainandoffchainservices,triggeringpaymentsautonomously.

Thisenablesfullyautonomous,AI-drivencommerce—allowinggoal-orientedagentstooperateindependentlyinanon-demand,permissionlesseconomy.

EnablingNewBusinessModels

PragmaticMicropayments

Legacypaymentrailsoperateonanaccount-basedmodelandgenerallyrequiresomedegreeoftrust/creditriskamongcounterparties.

Theserailsweredesignedforhumans,anddon’tworkforsmall,high-frequencytransactionalserviceslikeAPIrequests.Withfeesashighas$0.30pertransaction,microtransactionsbecomeimpractical—forcingbusinessestorelyonsubscriptionsandbundledpricing,causingmanypotentialconsumerstoabstainfromuse.

Asapaymentprotocol,x402makesitpossibletochargeperrequest,perservice,orpersecondofusagewith:

•Near-zerotransactioncoststhatenablepaymentsaslowas$0.001centsperrequest.

•Truepay-per-usepricingforAPIs,AIinference,andon-demandcontent.

•Machine-to-machinetransactionsthatallowIoTdevicesandAIagentstoautonomouslypayforresources.

Forthefirsttime,businessescanprofitablysupportmicropaymentsatscale,creatingnewmonetizationopportunitiesforAI-drivenplatforms.ThisismadepossiblebecauseoflowcostandhighspeedoftransactionsonrollupslikeBase,andtrustworthystablecoinslikeUSDCthatarepeggedtotheUSD.

SeamlessPay-Per-UseMonetization

Acceptingpaymentsonlinehastraditionallymeantforcingusersintoaccounts,managingAPIkeys,andhandlingmanualbillingcycles.x402removesthesebarriersbyoffering:

•Seamlessper-requestpayments—Nosubscriptions,noprepayments,nolock-in.

•Instant,finalizedtransactions—Nochargebacks,nofraudrisks,nointermediaries.

•AI-nativemonetization—LetAIagentsandhumanuserspaydynamicallywithoutpre-approvalsorAPIkeys.

Fordevelopersandbusinesses,thismeanshigherrevenue,lowercosts,andaseamlesspaymentexperience.

SimplifyingPaymentsOperations

MitigatingFraud,Chargebacks,andComplianceOverhead

Beyondtransactionfees,legacypaymentsystemsexposebusinessestorisksofchargebacks,fraud,operationallosses,andcomplianceoverhead.Withx402:

•Paymentssettleinstantlyonchain,eliminatingchargebacksanddisputes.

x402WhitepaperCoinbaseDeveloperPlatform

9

•NoPCIcompliancerequiredfordevelopers,unlessafacilitatorchoosestoacceptcardpaymentsdirectly

•Norelianceonbanksorthird-partyapprovals,ensuringglobal,permissionlessaccess.

Byremovingtheseroadblocks,x402allowsbusinessestofocusongrowth,notpaymentcomplexities.

Future-Proof,Chain-andToken-AgnosticPayments

x402isbuilttosupportanystablecoin,digitalasset,orblockchain—unlockingflexibilitybeyondtraditionalpaymentproviders.

•WhileUSDCisoneofthefirstsupportedassets,x402isdesignedtosupportstablecoins,digitalassets,andmultipleblockchainnetworks.

•Businessesanddeveloperscanchoosethebestcryptocurrencyfortheirusecase,ensuringmaximumflexibility.

Thisfuture-readydesignensuresthatx402willcontinueevolvingasAI-drivencommercescales.

Thex402Spec:AFlexible

HTTPStandardforPayments

Thex402middlewareisalightweightintegrationthatenablespay-per-requestAPIpayments.Thefollowingsectiondetailshowdeveloperscanconfigurex402andhowAIagentshandlepayment-requiredresponsesinrealtime.

MiddlewareConfiguration

paymentMiddleware(amount:"0.10",address:"0x...")

Parameter

Description

amount

Costperrequest(e.g.,”$0.10”)

address

Walletaddresswherepaymentsarereceived

HandlingRequestsWithoutPayment

Ifarequestissubmittedwithoutpayment,theserverrespondswith

HTTP402

(PaymentRequired).TheresponseprovidesstructuredfeedbackforAIagentsandhumans,including:

{

"maxAmountRequired":"0.10",

"resource":"/api/market-data",

"description":"Accesstoreal-timemarketdatarequirespayment.",

"payTo":"0xABCDEF1234567890ABCDEF1234567890ABCDEF12","asset":"0xA0b86991C6218b36c1d19D4a2e9Eb0cE3606EB48","network":"ethereum-mainnet"

}

x402WhitepaperCoinbaseDeveloperPlatform

10

Field

Description

maxAmountRequired

Paymentamountrequiredforaccess(e.g.,$0.10)

resource

TherequestedAPIendpointorservice

description(optional)

Custommessagedescribingpaymentdetails

payTo

Developer’swalletaddress(receivingpayment)

asset

Contractaddressforthetransaction

network

Blockchainnetworkidentifier

TechnicalSpecifications

x402implementsastandardizedapproachto

HTTP402responseswithprecisespecificationsforpayment

requestsandverification.

PaymentRequestFormat

WhenanAPIreturnsa402response,itincludesastructuredJSONpayloadwiththefollowingfields:

Field

Description

maxAmountRequired

Maximumpaymentamountrequired(e.g.,”0.10”)

assetType

Tokenstandard(e.g.,”ERC20”)

assetAddress

Contractaddressofthepaymenttoken

paymentAddress

Recipient’swalletaddress

network

Blockchainnetworkidentifier(e.g.,”base-mainnet”)

expiresAt

Timestampafterwhichthispaymentrequestisnolongervalid

nonce

Uniqueidentifiertopreventreplayattacks

paymentId

Uniqueidentifierforthispaymentrequest

PaymentAuthorization

Whensubmittingpayment,clientsincludeacryptographicallysignedmessagecontaining:

•Allfieldsfromthepaymentrequest

•Theactualpaymentamount(mustbe≤maxAmountRequired)

•Timestampoftheauthorization

•Cryptographicsignaturefromthepayingwallet

ThesignaturefollowstheEIP-712standard,enablingclearandsecurepresentationinwalletinterfaceswhenusersauthorizetransactions.

TransactionSettlement

x402implementationscanhandlesettlementthroughvariousmethods:

x402WhitepaperCoinbaseDeveloperPlatform

11

•On-chainsettlement:Directblockchaintransactions

•Layer-2settlement:UsingoptimisticorZKrollupsforlowerfees

•Paymentchannels:Forhigh-frequencymicropaymentsbetweentrustedparties

•Batchedsettlements:Combiningmultiplemicropaymentsintoasingletransaction

Thisflexibilityallowsdeveloperstochoosethemostefficientsettlementmechanismfortheirspecificusecaseandtransactionvolume.

IntegrationExamples

x402isdesignedforstraightforwardintegrationacrossvariousprogramminglanguagesandframeworks.

Server-SideImplementation

ForNodeJSapplicationsusingExpress:

//Installwith:npminstall@x402/express-middleware

constexpress=require(’express’);

const{x402PaymentRequired}=require(’@x402/express-middleware’);

constapp=express();

app.get(’/premium-data’,x402PaymentRequired({amount:"0.10",

address:"0x1234...",

assetAddress:"0x2345...",//USDCcontract

network:"base-mainnet"}),(req,res)=>{

//Thiscodeonlyrunsaftervalidpayment

res.json({premiumData:"Valuableinformation"});});

app.listen(3000);

Client-SideImplementation

Forwebapplicationsusingthex402clientlibrary:

12

//Installwith:npminstall@x402/client

import{x402Client}from’@x402/client’;

import{connectWallet}from’your-wallet-connector’;

constclient=newx402Client();

constwallet=awaitconnectWallet();

//Configuretheclientwiththeuser’swalletclient.setWallet(wallet);

//MakeAPIrequestswithautomaticpaymenthandlingtry{

constdata=awaitclient.fetch(’

/premium-data

’);console.log(data);//Thepremiumdata

}catch(error){

console.error(’Paymentfailed:’,error);}

WalletIntegration

x402isdesignedtoworkwithanycryptocurrencywalletthatsupportsstandardsigningmethods.Whenapaymentisrequired,thewalletinterfacedisplaysaconfirmationscreenshowing:

•Therequestdomain(e.g.,)

•Therequestedpaymentamount

•Thepaymenttoken(e.g.,USDC)

•Thespecificresourcebeingaccessed

Thistransparencyensuresusersalwaysknowexactlywhatthey’repayingfor,maintainingtrustbetweenserviceprovidersandusers.

TestingandDevelopment

Thex402toolkitincludesalocaldevelopmentenvironmentwith:

•Testwalletspre-loadedwithtesttokens

•MockAPIserversimplementingthex402protocol

•Toolingforsimulatingvariouspaymentscenarios

•Detailedloggingfordebuggingpaymentflows

Thesetoolsallowdeveloperstobuildandtestx402integrationswithoutconnectingtoproductionblockchainsorspendingrealtokens.

x402WhitepaperCoinbaseDeveloperPlatform

13

UseCases:RealWorldApplicationsofx402

Here’showAIagentsandhumansareusingx402invariouscontexts:

AgentsAccessingAPIsforOnDemandRequests

•Aresearchplatformenablespay-per-articleaccess,eliminatingbundledpaywallsandallowingAI-driventoolstopayonlyforrelevantcontent.

•Avideostreamingserviceleveragesx402tochargepersecondofcontentwatched,replacingtraditionalsubscription-basedmonetization.

•AtradingAIretrievesreal-timestockmarketdatafor$0.02perrequest,payingonlywhenneeded.

Pay-Per-UseAIModelInferenceMonetization

•AcomputervisionAPIcharges$0.005perimageclassificationinsteadofafixedenterprisefee.

•AsyntheticvoiceAIcharges$0.10peraudioclip,enablingflexiblemonetization.

AgentsPayingforCloudCompute&Storage

•AnautonomousagentpurchasesGPUresourcesfor$0.50perGPU-minute,payingpercomputecycle.

•Agoal-drivenAImodelexpandscloudstorageasneededforcontextandreinforcementlearning,payingperGBstored.

ContextRetrievalforAgents

•AfinancialAIassistantpays$0.25perpremiumnewsarticleforresearch.

•Alegalresearchagentaccessescourtrulingsat$0.10perdocument,avoidingfulldatabasesubscrip-tions.

MicropaymentsforHumanAccesstoContent

•ASubstackwritercharges$0.25perarticleforcasualreaders,allowingpay-as-you-goaccessinsteadoffullsubscri

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论