Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EIP-5388: Token-Gated HTTP Endpoints #5388

Closed

Conversation

TimDaub
Copy link
Contributor

@TimDaub TimDaub commented Aug 1, 2022

For now, I'm submitting this proposal as a draft. It essentially generalizes token-gating as implemented by e.g. Ocean Protocol.

Summary of this PR:
Screenshot 2022-08-01 at 16 48 33

https://twitter.com/timdaub/status/1554116824006103040

What I could need help with:

  • Not sure what exactly I should write in the "Rationale" section
  • Is it fine to ignore the backward compatibility section for now? It seems this proposal doesn't have to be backward compatible
  • What would be the security implications of such a standard?
  • Have I outlined the EIP-712 section well? My confidence in working with EIP-712 is low, so I'd appreciate feedback, safety reviews, and help

TODOs:

  • X-ABI-ENCODED-INPUT should be prefixed with `EIP-XXXX´ too
  • Create Magician's thread
  • When requesting the endpoint with authorization, we should probably mandate that the user submits a transaction ID with the executed suggestion too
  • A server must send a chain-ID along with the suggested encoded abi and a contract address
  • Consider removing the X- prefix from headers
  • Consider giving advice about "payable" value in case ETH is expected

EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
@eth-bot
Copy link
Collaborator

eth-bot commented Aug 1, 2022

Hi! I'm a bot, and I wanted to automerge your PR, but couldn't because of the following issue(s):


(fail) eip-5388.md

classification
newEIPFile

EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

The commit a073021 (as a parent of 2399a6f) contains errors. Please inspect the Run Summary for details.

EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the ambiguous label Aug 1, 2022
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

The commit 361a52e (as a parent of 14d0e5c) contains errors. Please inspect the Run Summary for details.

Copy link
Member

@Pandapip1 Pandapip1 left a comment

Choose a reason for hiding this comment

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

First pass

EIPS/eip-XXXX.md Outdated

## Abstract

This standard introduces composable RESTful HTTPS and Solidity interfaces that e.g. enable paying to access HTTPS endpoints using [EIP-20](./eip-20.md) tokens.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This standard introduces composable RESTful HTTPS and Solidity interfaces that e.g. enable paying to access HTTPS endpoints using [EIP-20](./eip-20.md) tokens.
This EIP introduces composable RESTful HTTP and Solidity interfaces that e.g. enable paying to access HTTP endpoints using [EIP-20](./eip-20.md) tokens.

Nit

EIPS/eip-XXXX.md Outdated

## Motivation

According to RFC 7231, HTTPS status `402 Payment Required` is reserved for future use. But the future is now as Ethereum enables users to verify their identity with a server using public key infrastructure.
Copy link
Member

Choose a reason for hiding this comment

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

Something about "the future is now" rubs me the wrong way...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it's a bit too aggressive for a standard document. I'll make it more neutral.

EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated
"{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"type\":\"function\"}"
```

### Authorization via EIP-712 Signature
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
### Authorization via EIP-712 Signature
### Authorization via [EIP-712](./eip-712.md) Signature

EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
EIPS/eip-XXXX.md Outdated Show resolved Hide resolved
@TimDaub TimDaub changed the title Initial draft Initial draft for EIP-5388 Aug 1, 2022
@github-actions
Copy link

github-actions bot commented Aug 1, 2022

The commit e89bf56 (as a parent of 9b77df8) contains errors. Please inspect the Run Summary for details.

EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Outdated Show resolved Hide resolved

## Rationale

There is no rationale related this standard.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
There is no rationale related this standard.
TBD

EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Outdated Show resolved Hide resolved
EIPS/eip-5388.md Show resolved Hide resolved
EIPS/eip-5388.md Show resolved Hide resolved
@TimDaub TimDaub changed the title Initial draft for EIP-5388 Initial draft for EIP-5388 Token-Gated HTTP Endpoints Aug 4, 2022
Upon the user's initial request, a HTTPS server implementing token-gating via EIP-5388 responds with a `402 Payment Required` status code:

- Its body must include a valid JSON string that complies with the Solidity Contract ABI Specification for calling contracts.
- It must include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.
Copy link

Choose a reason for hiding this comment

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

The use of the X- prefix, while very common is actually considered useless (if not harmful..) so I think it would be ok to skip it in favor EIP-5388.

Copy link

Choose a reason for hiding this comment

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

I think it is important to make sure this address is compatible beyond Ethereum mainnet by adding the chain id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use of the X- prefix, while very common is actually considered useless (if not harmful..) so I think it would be ok to skip it in favor EIP-5388.

Can u please add a reference that explains why the X- prefix is harmful/useless?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is important to make sure this address is compatible beyond Ethereum mainnet by adding the chain id.

Makes sense, will add it.

Copy link
Member

Choose a reason for hiding this comment

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

Can u please add a reference that explains why the X- prefix is harmful/useless?

X- headers are for non-standardized headers. So if I have an Application A that needs to return a custom header (for some reason), I should prefix it with X-.

This is a standard. You can (and should) drop the X-.

Choose a reason for hiding this comment

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

Can u please add a reference that explains why the X- prefix is harmful/useless?

There is a good SO thread there and my good friend Peter wrote an RFC a while back https://www.rfc-editor.org/rfc/rfc6648

https://stackoverflow.com/questions/3561381/custom-http-headers-naming-conventions

TimDaub and others added 3 commits August 4, 2022 13:12
Co-authored-by: Pandapip1 <[email protected]>
Co-authored-by: Pandapip1 <[email protected]>
Co-authored-by: Pandapip1 <[email protected]>
Co-authored-by: Pandapip1 <[email protected]>
@Pandapip1 Pandapip1 changed the title Initial draft for EIP-5388 Token-Gated HTTP Endpoints Add EIP-5388: Token-Gated HTTP Endpoints Aug 28, 2022
---
eip: 5388
title: Token-Gated HTTP Endpoints
description: Composable RESTful and Solidity interface to implement token-gated HTTP endpoints using data tokens.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think HTTP and RESTful can be decoupled. If this EIP mandates RESTful API, the title shall reflect it. If it only mandates HTTP, then I think we can drop the RESTful in the description and just keep it about HTTP endpoint?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Choose a reason for hiding this comment

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

Agreed, I am not sure REST is required/useful?

Copy link
Contributor

@xinbenlv xinbenlv Nov 11, 2022

Choose a reason for hiding this comment

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

Cool!

I kind of like to also have a RESTFul standard, but it can be one level above HTTP, hence that it self could have an separate EIP.

Upon the user's initial request, an HTTP server implementing token-gating via this EIP responds with a `402 Payment Required` status code:

- Its body must include a valid JSON string that complies with the Solidity Contract ABI Specification for calling contracts.
- It must include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- It must include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.
- It **MUST** include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.


- Its body must include a valid JSON string that complies with the Solidity Contract ABI Specification for calling contracts.
- It must include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.
- It must include a custom header `X-EIP-5388-ABI-ENCODED-INPUT` that suggests the call signature the user must invoke at `X-EIP-5388-CONTRACT-ADDRESS` to gain access to the endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- It must include a custom header `X-EIP-5388-ABI-ENCODED-INPUT` that suggests the call signature the user must invoke at `X-EIP-5388-CONTRACT-ADDRESS` to gain access to the endpoint.
- It **MUST** include a custom header `X-EIP-5388-ABI-ENCODED-INPUT` that suggests the call signature the user must invoke at `X-EIP-5388-CONTRACT-ADDRESS` to gain access to the endpoint.


- Its body must include a valid JSON string that complies with the Solidity Contract ABI Specification for calling contracts.
- It must include a custom header `X-EIP-5388-CONTRACT-ADDRESS` that suggests the contract's address a call must be directed to.
- It must include a custom header `X-EIP-5388-ABI-ENCODED-INPUT` that suggests the call signature the user must invoke at `X-EIP-5388-CONTRACT-ADDRESS` to gain access to the endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel the spec also lacks a part in solidity interface for what smart contract it will be to respond to a end point request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I understand what you mean, would you mind elaborating?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think what @xinbenlv is asking is probably which are these contracts that these endpoints might be dependent on, as suggested in his changes. Is that it?

Co-authored-by: Pandapip1 <[email protected]>
@github-actions github-actions bot added c-new Creates a brand new proposal s-draft This EIP is a Draft t-erc labels Sep 25, 2022
Co-authored-by: Pandapip1 <[email protected]>
@Rachi26
Copy link

Rachi26 commented Sep 25, 2022

شكرا


## Abstract

This standard introduces composable RESTful HTTP and Solidity interfaces that enable paying to access HTTP endpoints using [EIP-20](./eip-20.md) tokens.

Choose a reason for hiding this comment

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

I am not sure it is about REST?
Also, why require ERC20... I think it could be more flexible...

Choose a reason for hiding this comment

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

This standard introduces composable HTTP and Solidity interfaces that enable restricting to access HTTP endpoints using smart contracs.

Copy link

@julien51 julien51 left a comment

Choose a reason for hiding this comment

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

I think the general idea is a very good one, but this needs more generalization!

Ideally the HTTP server would return a way for the user agent (browser) to know what it will perform as verification in order to check if the user(identified via the signature) should be grated access, but also offer (optionally) a way for the user agent to actually trigger a transaction that would satisfy the conditional access.

So you'd have a flow like this:

  • User agent queries server
  • Server responds: I need to know who you are (please sign a message) and once I know I will run this check on the chain. If you want this check to be "positive" here is what you need to do "optionally".
  • UA can then request user to sign, and once they have can check if indeed the user satisfies the required condition to get access.
  • If so, UA (re)sends request with the appropriate header to identify user
  • If not, UA prompts users to execute the transaction that would satisfy condition (a smart UA could even simulate the tx to verify that indeed it satisfies the condition).
  • Once Tx confirmed, the UA could (re)send request to the server

I think it would be useful to think of making the user identification itself flexible, because we may want to eventually support privacy preserving approaches where the UA does not submit a signature but a proof (zk?) that they satisfy the condition prompted by the server.

@github-actions
Copy link

There has been no activity on this pull request for 2 weeks. It will be closed after 3 months of inactivity. If you would like to move this PR forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added w-stale Waiting on activity and removed w-stale Waiting on activity labels Nov 26, 2022
@github-actions
Copy link

There has been no activity on this pull request for 2 weeks. It will be closed after 3 months of inactivity. If you would like to move this PR forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the w-stale Waiting on activity label Dec 12, 2022
@github-actions
Copy link

This pull request was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

@github-actions github-actions bot closed this Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-new Creates a brand new proposal s-draft This EIP is a Draft t-erc w-stale Waiting on activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants