Skip to content

Commit

Permalink
Repo la Mono
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed May 25, 2024
1 parent 194993f commit 4687881
Show file tree
Hide file tree
Showing 44 changed files with 82 additions and 73 deletions.
75 changes: 2 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,7 @@
> [!WARNING]
> This repository is under construction 🚧. We are actively improving it hackathon-style.
This is a Rust implementation of the [CCIP gateway](https://alpha-docs.ens.domains/resolvers/ccip). It allows you to issue unlimited gasless subdomains for your name, as well as to create, manage, and moderate namespaces.
## Offchain Gateway Example

> [!NOTE]
> This gateway is built to be an **Opinionated ENS Subname Issuer**, if youre looking for something more generic, please checkout [ensdomains/offchain-resolver](https://github.com/ensdomains/offchain-resolver), and [ensdomains/offchain-resolver-example](https://github.com/ensdomains/offchain-resolver-example).
If you are looking for the original code that was in this repository please see [examples/full](examples/full).

## Features

- CCIP Spec Compliant Gateway Endpoint
- `postgres` - Transparent Database backend.
- `self-service` - Authentication-based updating records.
- `eoa-self-service` - EOA-based Authentication. (TODO)
- Modular authentication for EOA, Admin API, & more.
- View endpoint for profile data.

## Setup

### Run the gateway
The gateway is just a docker container / standalone binary. You can run it with docker-compose or just run the binary.

```yaml
cargo run
```

### Deploy a Resolver

Using a CCIP Gateway requires a resolver contract to be acting on behalf of the name. Although you could write your own contract, we recommend you deploy a proxy contract through [ccip.tools](https://ccip.tools/).

[![](.github/ccip-tools.png)](https://ccip.tools/)

(Source for the contracts can be found at [ensdomains/ccip-tools](https://github.com/ensdomains/ccip-tools/tree/master/contracts))

When asked for the `Gateway URL` supply your gateway's url (for eg: `https://gateway.example.com/{sender}.json`), and for the `Signers` field supply the address of your gateway (for eg: `[0x225f137127d9067788314bc7fcc1f36746a3c3B5]`), you can find this in the logs of your gateway.

> [!NOTE]
> There are gas costs associated with deploying a resolver, at the time of writing this (30 gwei), it costs ~0.004 ETH (8 USD) to deploy a resolver (see [txs](https://etherscan.io/tx/0x0c90da0a122f38125a8ad1f48ef23cf5f7d399846bd5369b664ff288a31f797c)).
### Set your Resolver

Finally you need to instruct the onchain registry to use your resolver. You can do this by visiting your name in the [ENS Manager App](https://ens.app/) and under the `More` tab, set the `Resolver` field to the address of your resolver.

## Fork this 🍴
Don't like the implementation? Fork this repo and make it your own!

You might also be interested in the [resolution logic](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/gateway/resolution.rs) and [database modularity](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/database/mod.rs).

## Integration

This gateway implementation is designed to be modular, light, and easy to integrate. It comes with the abstract Datastore idea, (by default implemented with postgres), authentication, simple resolution logic, and a self-service API.

This means that depending on your use case you can easily swap out the database, the resolution logic, and customize authentication.

### Issuing a name

To issue a name from an trusted server, you can simply `POST` to `example.com/update` with a JSON body such as

```json
{
"name": "luc.willbreak.eth",
"records": {
"name": "Luc",
"text": "hello world",
"avatar": "https://avatars.githubusercontent.com/u/11744586?v=4",
},
"addresses": {
"60": "0x225f137127d9067788314bc7fcc1f36746a3c3B5"
},
"auth": "yes"
}
```

In a similar fashion users could self-service their names by using this api endpoint and custom authentication logic.

### Viewing a name

In events were our app might not have access to ethereum specific tooling, we can use the `GET` endpoint `example.com/view/luc.willbreak.eth` to view the data of a name. This endpoint can be helpful for showing profile editing pages and more.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 80 additions & 0 deletions examples/full/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Offchain Gateway (Rust)

> [!WARNING]
> This repository is under construction 🚧. We are actively improving it hackathon-style.
This is a Rust implementation of the [CCIP gateway](https://alpha-docs.ens.domains/resolvers/ccip). It allows you to issue unlimited gasless subdomains for your name, as well as to create, manage, and moderate namespaces.

> [!NOTE]
> This gateway is built to be an **Opinionated ENS Subname Issuer**, if youre looking for something more generic, please checkout [ensdomains/offchain-resolver](https://github.com/ensdomains/offchain-resolver), and [ensdomains/offchain-resolver-example](https://github.com/ensdomains/offchain-resolver-example).
## Features

- CCIP Spec Compliant Gateway Endpoint
- `postgres` - Transparent Database backend.
- `self-service` - Authentication-based updating records.
- `eoa-self-service` - EOA-based Authentication. (TODO)
- Modular authentication for EOA, Admin API, & more.
- View endpoint for profile data.

## Setup

### Run the gateway
The gateway is just a docker container / standalone binary. You can run it with docker-compose or just run the binary.

```yaml
cargo run
```

### Deploy a Resolver

Using a CCIP Gateway requires a resolver contract to be acting on behalf of the name. Although you could write your own contract, we recommend you deploy a proxy contract through [ccip.tools](https://ccip.tools/).

[![](.github/ccip-tools.png)](https://ccip.tools/)

(Source for the contracts can be found at [ensdomains/ccip-tools](https://github.com/ensdomains/ccip-tools/tree/master/contracts))

When asked for the `Gateway URL` supply your gateway's url (for eg: `https://gateway.example.com/{sender}.json`), and for the `Signers` field supply the address of your gateway (for eg: `[0x225f137127d9067788314bc7fcc1f36746a3c3B5]`), you can find this in the logs of your gateway.

> [!NOTE]
> There are gas costs associated with deploying a resolver, at the time of writing this (30 gwei), it costs ~0.004 ETH (8 USD) to deploy a resolver (see [txs](https://etherscan.io/tx/0x0c90da0a122f38125a8ad1f48ef23cf5f7d399846bd5369b664ff288a31f797c)).
### Set your Resolver

Finally you need to instruct the onchain registry to use your resolver. You can do this by visiting your name in the [ENS Manager App](https://ens.app/) and under the `More` tab, set the `Resolver` field to the address of your resolver.

## Fork this 🍴
Don't like the implementation? Fork this repo and make it your own!

You might also be interested in the [resolution logic](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/gateway/resolution.rs) and [database modularity](https://github.com/ensdomains/offchain-gateway-rs/blob/main/src/database/mod.rs).

## Integration

This gateway implementation is designed to be modular, light, and easy to integrate. It comes with the abstract Datastore idea, (by default implemented with postgres), authentication, simple resolution logic, and a self-service API.

This means that depending on your use case you can easily swap out the database, the resolution logic, and customize authentication.

### Issuing a name

To issue a name from an trusted server, you can simply `POST` to `example.com/update` with a JSON body such as

```json
{
"name": "luc.willbreak.eth",
"records": {
"name": "Luc",
"text": "hello world",
"avatar": "https://avatars.githubusercontent.com/u/11744586?v=4",
},
"addresses": {
"60": "0x225f137127d9067788314bc7fcc1f36746a3c3B5"
},
"auth": "yes"
}
```

In a similar fashion users could self-service their names by using this api endpoint and custom authentication logic.

### Viewing a name

In events were our app might not have access to ethereum specific tooling, we can use the `GET` endpoint `example.com/view/luc.willbreak.eth` to view the data of a name. This endpoint can be helpful for showing profile editing pages and more.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4687881

Please sign in to comment.