curl --request POST \
--url https://harness.chance.cc/api/v1/credits/topup \
--header 'x-api-key: <api-key>'import requests
url = "https://harness.chance.cc/api/v1/credits/topup"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://harness.chance.cc/api/v1/credits/topup', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://harness.chance.cc/api/v1/credits/topup",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://harness.chance.cc/api/v1/credits/topup"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://harness.chance.cc/api/v1/credits/topup")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://harness.chance.cc/api/v1/credits/topup")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"credited": 200,
"usd": "10.00",
"creditsRemaining": 203,
"txHash": "0x…",
"payer": "0x…",
"replayed": false
}Add account balance with x402
Pays USDC on Base (eip155:8453) over x402 v2. Name the account with an API key or with ?account=. Without a payment the response is 402 with a PAYMENT-REQUIRED header. Sign the EIP-3009 authorization it describes and retry with PAYMENT-SIGNATURE. Credits are added after settlement, once per authorization. A plain USDC transfer credits nothing.
curl --request POST \
--url https://harness.chance.cc/api/v1/credits/topup \
--header 'x-api-key: <api-key>'import requests
url = "https://harness.chance.cc/api/v1/credits/topup"
headers = {"x-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'x-api-key': '<api-key>'}};
fetch('https://harness.chance.cc/api/v1/credits/topup', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://harness.chance.cc/api/v1/credits/topup",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://harness.chance.cc/api/v1/credits/topup"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://harness.chance.cc/api/v1/credits/topup")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://harness.chance.cc/api/v1/credits/topup")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"credited": 200,
"usd": "10.00",
"creditsRemaining": 203,
"txHash": "0x…",
"payer": "0x…",
"replayed": false
}Authorizations
An API key (chance_sk_live_…) from https://harness.chance.cc/keys.
Query Parameters
Whole US dollars to add. Use either usd or credits, not both.
1 <= x <= 2000Legacy credit quantity; use either usd or credits, not both. Limits are deployment-specific.
20 <= x <= 10000Public top-up code (chance_topup_…). Use it instead of an API key to pay for another account. Ignored when an API key is sent.
Response
Settled and credited. PAYMENT-RESPONSE carries the settlement.
200
"10.00"
New balance. Only returned when the request authenticated with an API key.
203
Base settlement transaction.
Address that signed the payment.
True when this payment was already credited and the original result is returned.

