Got example working against prod

This commit is contained in:
Chris Troutner
2026-04-21 19:24:56 -07:00
parent 336573d9f5
commit 0fa46c7109
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ export PORT=5942
# x402 payments required to access this API? # x402 payments required to access this API?
export X402_ENABLED=true export X402_ENABLED=true
export SERVER_BASE_ADDRESS=0xd32585CE60815654C50CAf350e18de8096061e63 export SERVER_BASE_ADDRESS=0xd32585CE60815654C50CAf350e18de8096061e63
export X402_PRICE_USDC=0.1 export X402_PRICE_USDC=0.001
# Network configuration (CAIP-2 format required by CDP) # Network configuration (CAIP-2 format required by CDP)
# Use 'eip155:8453' for Base mainnet # Use 'eip155:8453' for Base mainnet
+8 -3
View File
@@ -15,13 +15,15 @@ import { x402Client, wrapAxiosWithPayment } from '@x402/axios'
import { registerExactEvmScheme } from '@x402/evm/exact/client' import { registerExactEvmScheme } from '@x402/evm/exact/client'
import { toClientEvmSigner } from '@x402/evm' import { toClientEvmSigner } from '@x402/evm'
const baseURL = 'http://localhost:5942' // Local // const baseURL = 'http://localhost:5942' // Local
// const baseURL = 'https://x402.fullstack.cash' // Production const baseURL = 'https://x402.fullstack.cash' // Production
const endpointPath = '/v6/full-node/blockchain/getBlockchainInfo' const endpointPath = '/v6/full-node/blockchain/getBlockchainInfo'
const pKey = process.env.PRIVATE_KEY || process.env.EVM_PRIVATE_KEY || '' const pKey = process.env.PRIVATE_KEY || process.env.EVM_PRIVATE_KEY || ''
console.log('pKey: ', pKey)
const x402Network = 'eip155:8453' // sepolia eip155:84532 // const x402Network = 'eip155:84532' // sepolia eip155:84532
const x402Network = 'eip155:8453' // mainnet eip155:8453
if (!pKey) throw new Error('PRIVATE_KEY or EVM_PRIVATE_KEY env required!') if (!pKey) throw new Error('PRIVATE_KEY or EVM_PRIVATE_KEY env required!')
@@ -53,6 +55,7 @@ const api = wrapAxiosWithPayment(
}), }),
client client
) )
const request = async () => { const request = async () => {
console.log('\n\nStep 1: Making first call, expecting a 402 error returned.') console.log('\n\nStep 1: Making first call, expecting a 402 error returned.')
try { try {
@@ -78,10 +81,12 @@ const request = async () => {
} catch (err) { } catch (err) {
console.log('Step 2 failed. Expected a 200 success status code.') console.log('Step 2 failed. Expected a 200 success status code.')
console.log(`Status code: ${err?.response?.status}`) console.log(`Status code: ${err?.response?.status}`)
// console.log('err: ', err)
console.log( console.log(
`Error StatusText: ${JSON.stringify(err.response.statusText, null, 2)}` `Error StatusText: ${JSON.stringify(err.response.statusText, null, 2)}`
) )
console.log(`Error data: ${JSON.stringify(err.response.data, null, 2)}`) console.log(`Error data: ${JSON.stringify(err.response.data, null, 2)}`)
console.log('payment-required header: ', err.response.headers['payment-required'])
process.exit(1) process.exit(1)
} }