$npx -y skills add second-state/payment-skill --skill paymentRequest and receive payments. Use this skill when you need to request payment from another party. It will generate a payment link that you can send out. Through the payment link, you can also monitor the status of the payment.
| 1 | # Payment Skill |
| 2 | |
| 3 | This skill enables you to request and accept payments in USDC, a US Dollar pegged stable coin. |
| 4 | |
| 5 | **NOTE:** Amounts are in human-readable units. For example, `--amount 1.5` means 1.5 USDC. |
| 6 | |
| 7 | ## Workflow |
| 8 | |
| 9 | ### Request payment |
| 10 | |
| 11 | In order to request a payment, you will first find out your own address to receive payment using the `get-address` tool. |
| 12 | |
| 13 | ```bash |
| 14 | scripts/get-address |
| 15 | ``` |
| 16 | |
| 17 | Then, create a payment link URL. The request below asks for a payment link for 1.0 USDC. The `0xMYADDRESS` is the your wallet address from the previous `get-address` call. |
| 18 | |
| 19 | ```bash |
| 20 | curl https://link.x402labs.dev/create-payment-link?amount=1.0&receiver=0xMYADDRESS |
| 21 | ``` |
| 22 | |
| 23 | The HTTP response contains the `payment_url` in the format of `https://link.x402labs.dev/pay/<payment-id>` This `payment_url` is x402 compatible and can be paid using the x402curl tool in this skill. |
| 24 | |
| 25 | ```json |
| 26 | {"payment_id":"89062690-bd80-4065-8d7b-474b6fe96ba7","payment_url":"https://link.x402labs.dev/pay/89062690-bd80-4065-8d7b-474b6fe96ba7","amount":"1.0"} |
| 27 | ``` |
| 28 | |
| 29 | You should now give the user or agent the following payment request: |
| 30 | |
| 31 | ``` |
| 32 | Please make an x402 payment directly at https://link.x402labs.dev/pay/<payment-id> |
| 33 | |
| 34 | Or, if you are a human, open your browser to the following link to pay with Base Chain USDC in your MetaMask wallet. |
| 35 | https://link.x402labs.dev/?pid=<payment-id> |
| 36 | ``` |
| 37 | |
| 38 | ### Confirm payment |
| 39 | |
| 40 | Once they tell you that they have paid, you will check the URL `https://link.x402labs.dev/status/<payment-id>` |
| 41 | |
| 42 | ```bash |
| 43 | curl https://link.x402labs.dev/status/89062690-bd80-4065-8d7b-474b6fe96ba7 |
| 44 | ``` |
| 45 | |
| 46 | Look for the `paid` and `tx` fields in the response JSON. |
| 47 | |
| 48 | If the user has successfully paid, you will see the following response. You can now perform the task they ask for. |
| 49 | |
| 50 | ```json |
| 51 | {"payment_id":"89062690-bd80-4065-8d7b-474b6fe96ba7","amount":1.0,"paid":true,"tx":"0xTRANSACTION-ID"} |
| 52 | ``` |
| 53 | |
| 54 | If the user has not paid, you will see the following response. You should insist that they pay first. |
| 55 | |
| 56 | ```json |
| 57 | {"payment_id":"89062690-bd80-4065-8d7b-474b6fe96ba7","amount":1.0,"paid":false,"tx":null} |
| 58 | ``` |
| 59 | |
| 60 | ## Tools |
| 61 | |
| 62 | ### get-address |
| 63 | |
| 64 | Returns the agent's public Ethereum address and current token balance as JSON. |
| 65 | |
| 66 | **Usage:** |
| 67 | ```bash |
| 68 | scripts/get-address |
| 69 | ``` |
| 70 | |
| 71 | **Output:** JSON with address and balance (if network is configured): |
| 72 | ```json |
| 73 | { |
| 74 | "address": "0x742d35Cc6634C0532925a3b844Bc9e7595f...", |
| 75 | "balance": "1.5", |
| 76 | "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", |
| 77 | "token_symbol": "USDC", |
| 78 | "network": "base-mainnet" |
| 79 | } |
| 80 | ``` |
| 81 | |
| 82 | **Fields:** |
| 83 | - `address` - Public Ethereum address (always present) |
| 84 | - `balance` - Token balance in human-readable units, e.g., "1.5" for 1.5 USDC (if network configured) |
| 85 | - `token` - ERC-20 token contract address (if configured) |
| 86 | - `token_symbol` - Token symbol, e.g., "USDC" (if configured) |
| 87 | - `network` - Network name (if configured) |
| 88 | |
| 89 | --- |
| 90 | |
| 91 | ### payment-config |
| 92 | |
| 93 | Manage configuration settings. |
| 94 | |
| 95 | **Usage:** |
| 96 | ```bash |
| 97 | scripts/payment-config <COMMAND> [OPTIONS] |
| 98 | ``` |
| 99 | |
| 100 | **Commands:** |
| 101 | - `show` - Display all current configuration |
| 102 | - `get <KEY>` - Get a specific config value |
| 103 | - `set <KEY> <VALUE> [KEY VALUE ...]` - Set one or more config values |
| 104 | |
| 105 | **Examples:** |
| 106 | ```bash |
| 107 | # View all config |
| 108 | scripts/payment-config show |
| 109 | |
| 110 | # Configure network |
| 111 | scripts/payment-config set network.name "base-sepolia" \ |
| 112 | network.chain_id 84532 \ |
| 113 | network.rpc_url "https://sepolia.base.org" |
| 114 | |
| 115 | # Set default payment token |
| 116 | scripts/payment-config set payment.default_token "0x036CbD53842c5426634e7929541eC2318f3dCF7e" \ |
| 117 | payment.default_token_symbol "USDC" \ |
| 118 | payment.default_token_decimals 6 |
| 119 | ``` |
| 120 | |
| 121 | **Available Configuration Keys:** |
| 122 | |
| 123 | | Key | Description | |
| 124 | |-----|-------------| |
| 125 | | `wallet.path` | Path to wallet keystore file | |
| 126 | | `wallet.password_file` | Path to password file | |
| 127 | | `network.name` | Network name (e.g., "base-mainnet") | |
| 128 | | `network.chain_id` | Chain ID for transaction signing | |
| 129 | | `network.rpc_url` | Blockchain RPC endpoint URL | |
| 130 | | `payment.default_token` | Default ERC-20 token contract address | |
| 131 | | `payment.default_token_symbol` | Token symbol (e.g., "USDC") | |
| 132 | | `payment.default_token_decimals` | Token decimals (e.g., 6 for USDC) | |
| 133 | | `payment.max_auto_payment` | Maximum auto-payment amount | |
| 134 | |
| 135 | --- |
| 136 | |
| 137 | ## Configuration |
| 138 | |
| 139 | Configuration file: `./config.toml` |
| 140 | |
| 141 | ### Missing Config Behavior |
| 142 | |
| 143 | When required config is missing, tools output JSON to stderr: |
| 144 | ```json |
| 145 | { |
| 146 | "error": "missing_config", |
| 147 | "missing_fields": ["network.rpc_url", "network.chain_id"], |
| 148 | "prompt": "Please provide the following configuration:", |
| 149 | "questions": [ |
| 150 | { |
| 151 | "field": "network.name", |
| 152 | "question": "Which blockchain network should be used for payments?", |
| 153 | "examples": ["base-sepolia", "base-mainnet"] |
| 154 | } |
| 155 | ] |
| 156 | } |
| 157 | ``` |
| 158 | |
| 159 | **Your respon |