mirror of
https://github.com/Permissionless-Software-Foundation/psf-bch-api-base.git
synced 2026-09-21 16:52:00 -07:00
Got example working against prod
This commit is contained in:
+1
-1
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user