Book

 · 

To Base Chain

To Base Chain

To Base Chain

import { Controller } from "@hotwired/stimulus" import { wrapFetchWithPayment } from "x402-fetch" import { createWalletClient, custom } from "viem" import { baseSepolia, base } from "viem/chains" // 同时导入 mainnet,方便以后切换

export default class extends Controller { static targets = ["status", "post", "button"] static values = { url: String, // 可选:通过 data-attribute 指定目标链,默认 sepolia chain: String // "sepolia" 或 "mainnet" }

// 统一获取目标链配置 get targetChain() { const chain = this.chainValue || "sepolia" return chain === "mainnet" ? base : baseSepolia }

async pay() { this.buttonTarget.disabled = true this.buttonTarget.textContent = "连接中..."

if (!window.ethereum) {
this.statusTarget.textContent = "错误:请安装 MetaMask"
this.resetButton()
return
}

try {
/...
Currency-dollar 0.0800  USDC
Pay to @book
Wallet 0xc215...d7c7

Information-circle Not logged in. Payment will only be linked to wallet address.

Information-circle Payment goes directly to the author. For refunds, please contact the author.

Download Pickful App

Better experience on mobile

iOS QR

iOS

Android QR

Android

APK QR

APK