<sidejar-pay>
The payment button.
Attributes
| Attribute | Required | Meaning |
|---|---|---|
to |
yes | Your wallet address (receives the money). |
price |
yes | Amount in USDC, as a decimal: "0.20" is 20¢. From 0.05 (five cents) up to 5 USDC. The full amount reaches the recipient: no fees are taken out. |
item |
yes | A unique ID for what's being paid for. Each wallet can pay for an item only once. Add {date}, {week}, {month} or {year} to allow one payment per period (see below). |
network |
no | base (the default). base-sepolia (a test network with worthless USDC) exists for Sidejar's own development and logs a console warning. |
label |
no | The button's text, with {price} filled in: label="Tip the author {price}". Default: "Pay {price}". |
Your own label
Two ways, for the ready-to-pay button:
<!-- Text with the price filled in -->
<sidejar-pay to="0x…" price="0.20" item="post-42" label="Tip the author {price}"></sidejar-pay>
<!-- Or anything you put inside the tag (shown as-is, so write the price yourself) -->
<sidejar-pay to="0x…" price="0.20" item="post-42">☕ Buy me a coffee (20¢)</sidejar-pay>
Content inside the tag wins over label, and it's also what readers see if the script hasn't loaded. Other states ("Confirm in your wallet…", "Thanks! Paid…") keep Sidejar's wording.
Your own icon
The button shows Sidejar's jar before the label. To use your own, put it inside the tag with slot="icon": an image, an SVG or an emoji. It's sized to match the text.
<sidejar-pay to="0x…" price="0.20" item="post-42">
<img slot="icon" src="/my-logo.svg" alt="">
Support my writing
</sidejar-pay>
The "Thanks! Paid" message has its own slot, paid-icon. If you replace the button's icon but not the paid one, the paid message shows no icon rather than mixing styles. To remove the icon entirely: sidejar-pay::part(icon) { display: none; }.
Always close the tag: write
<sidejar-pay …></sidejar-pay>, never<sidejar-pay … />. HTML has no self-closing custom tags, so everything after a/>ends up inside the button. Sidejar notices this, ignores it as a label, and warns in the console. (JSX, Astro, Vue and Svelte handle/>for you.)
Paying again: dynamic item IDs
Each wallet can pay for an item once. To let people pay again (a tip jar, a daily donation), make the ID change over time with a placeholder:
<sidejar-pay to="0x…" price="1.00" item="support-{date}"></sidejar-pay>
| Placeholder | Becomes | One payment per wallet per… |
|---|---|---|
{date} |
2026-11-28 |
day |
{week} |
2026-W48 |
week (ISO, Monday to Sunday) |
{month} |
2026-11 |
month |
{year} |
2026 |
year |
Dates use the payer's local time zone, so "per day" rolls over at their own midnight. Events report the filled-in ID. For any other rule, set the attribute from your own script: jar.setAttribute("item", "anything-" + yourValue).
What payers see
| State | Button |
|---|---|
| No wallet installed | "To pay, you need a crypto wallet with a little USDC." with a "How to pay →" link to a short guide |
| Ready | "Pay 20¢", or "Pay 20¢ from 0x1a2…" when a wallet is already connected |
| Waiting | "Confirm in your wallet…" |
| Sending | "Sending payment…" |
| Paid | "Thanks! Paid 20¢", plus a "View transaction" link once confirmed |
| Error | A short message and "Try again" |
| Misconfigured | "This payment button is misconfigured." (check the console and sidejar:error) |
Payers need USDC in their wallet but no ETH: they sign once, and the payment service pays the network fee.
Events
All events are CustomEvents fired on the element. They bubble, so you can listen on document too.
| Event | When | detail |
|---|---|---|
sidejar:ready |
The button is set up | { network, walletDetected, connected, payer? } |
sidejar:paid |
Payment accepted, or already paid (on page load) | { item, payer, to, amount, nonce, restored, txHash? } |
sidejar:settled |
The transaction is confirmed on-chain | { item, payer, to, amount, nonce, txHash } |
sidejar:cancelled |
The payer declined in their wallet | { item, stage } ("connect", "switch" or "sign") |
sidejar:error |
Something failed, or a warning | { item, code, message, warning? } (see Error codes) |
document.querySelector("sidejar-pay").addEventListener("sidejar:paid", (e) => {
console.log(e.detail.restored ? "Paid earlier" : "Just paid", e.detail.amount);
});
amount is a decimal string like "0.20". restored: true means this wallet paid on an earlier visit: Sidejar remembers payments by checking the blockchain, so a returning payer is recognized without any account.
The element also has a read-only paidDetail property: the last sidejar:paid detail for the current payer, or null.
Styling
The button lives in shadow DOM, so your site's CSS can't break it. Style it with CSS custom properties:
sidejar-pay {
--sidejar-accent: #c2410c; /* button color */
--sidejar-radius: 6px;
}
| Property | Default use |
|---|---|
--sidejar-accent, --sidejar-accent-fg |
Button background (Sidejar teal, #0f766e, by default) and text |
--sidejar-fg, --sidejar-muted |
Text colors |
--sidejar-success, --sidejar-error, --sidejar-link |
Paid message, error message, links |
--sidejar-font, --sidejar-font-size |
Typography |
--sidejar-radius, --sidejar-padding |
Button shape |
The button shows Sidejar's jar icon before its label; its coin drops in while waiting and stacks up when paid. Hide it with sidejar-pay::part(icon) { display: none; }.
For more control, use the shadow parts jar, button, icon, message and link (sidejar-pay::part(button) { … }), or the element's data-state attribute (loading, nowallet, ready, waiting, sending, paid, error, invalid).