Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,80 @@ Expected response:
]
}
```
---

## Paymaster (Gasless Transactions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Paymaster is still in the experimental stage, could you please add a short disclaimer section to mention that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is meant by experimental? Isn't it deployed and anyone deploying their own JSON-RPC relay can use it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Keith sorry for the late response. So by experimental I meant that the Paymaster was implemented based on a POC and hasn’t gone through a full acceptance criteria review yet. It was built for a specific experimental use case requested previously, and only validated against successful (“happy path”) scenarios, not failure cases. So it might be unstable or prone to failure for now. That's why we should put a disclaimer for the section.


Starting in v0.71, the relay supports a Paymaster-style mode that allows operators to sponsor gas fees for selected users or contracts — enabling gasless transactions and simpler onboarding.

### Overview (Paymaster)

In traditional Web3 environments, every transaction must include a gas payment from the user’s account.
Hedera’s Paymaster-style model allows a relay or operator to safely and predictably cover gas fees for users.

#### Why It Matters

- Better UX — users can act without holding HBAR.
- Flexible monetization — sponsorship via credits or fiat.
- Enterprise and consumer use cases — onboarding, delegated submissions, sponsored dApps.
- Seamless integration — no changes to `msg.sender`.

### Configuration Overview

| Parameter | Description | Type | Default |
| ---------- | ------------ | ---- | -------- |
| PAYMASTER_ENABLED | Enables Paymaster functionality. | Boolean | false |
| PAYMASTER_WHITELIST | Whitelisted addresses eligible for sponsorship. Use `*` for all. | String | "" |
| MAX_GAS_ALLOWANCE_HBAR | Max HBAR subsidy per transaction. | Decimal | 0 |
Copy link
Member

@natanasow natanasow Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the codebase https://github.com/hiero-ledger/hiero-json-rpc-relay/blob/main/packages/relay/src/lib/clients/sdkClient.ts#L182, this is not a decimal. Here is the official doc https://docs.hedera.com/hedera/sdks-and-apis/sdks/smart-contracts/ethereum-transaction.

This value is denominated in tinybars, and yeah, the config name is a little bit misleading.


**Note:** `MAX_GAS_ALLOWANCE_HBAR` applies only if Paymaster is enabled and sender is whitelisted.
Senders must set `gasPrice=0` to trigger sponsorship.

### Behavior Summary

1. Enable Paymaster mode (`PAYMASTER_ENABLED=true`).
2. Define eligible addresses (`PAYMASTER_WHITELIST`).
3. Relay attaches a gas allowance up to `MAX_GAS_ALLOWANCE_HBAR`.
4. Payer covers cost; otherwise transaction proceeds normally.

### Example Configurations

```bash
# Demo / testnet
PAYMASTER_ENABLED=true
PAYMASTER_WHITELIST=*
MAX_GAS_ALLOWANCE_HBAR=0.15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

```

```bash
# Production
PAYMASTER_ENABLED=true
PAYMASTER_WHITELIST=0xabc123...,0xdef456...
MAX_GAS_ALLOWANCE_HBAR=0.10
```

### Example Use Cases

| Scenario | Description | Typical Settings |
| -------- | ------------ | ---------------- |
| App onboarding | Cover first user actions | PAYMASTER_ENABLED=true, PAYMASTER_WHITELIST=*, MAX_GAS_ALLOWANCE_HBAR=0.2 |
| Enterprise backend | Relay sponsors contract writes | PAYMASTER_ENABLED=true, PAYMASTER_WHITELIST=<contracts>, MAX_GAS_ALLOWANCE_HBAR=0.5 |
| Community relay | Sponsored dApp usage | PAYMASTER_ENABLED=true, PAYMASTER_WHITELIST=*, MAX_GAS_ALLOWANCE_HBAR=0.1 |

### Best Practices

- Always explicitly enable Paymaster.
- Use whitelisting for control.
- Start small (≤0.1 HBAR).
- Track and log sponsorship spend.
- Avoid `PAYMASTER_WHITELIST=*` in production.

### References

- PR #3941 — [Detailed Paymaster discussion](https://github.com/hiero-ledger/hiero-json-rpc-relay/pull/3941)
- [Relay Configuration Docs](https://github.com/hiero-ledger/hiero-json-rpc-relay)

---

## Support

Expand Down
Loading