near / bounties

Specs for technical and non-technical work that earns NEAR tokens
https://devgovgigs.near.social
72 stars 8 forks source link

NEAR <> Ceramic Clay Testnet Integration Example Apps #39

Closed mattlockyer closed 3 years ago

mattlockyer commented 3 years ago

Description

Create a sample app integrating with NEAR Wallet and Ceramic (optional have your own contract interactions) and have it be deployable on testnet by any developer who needs to use it as a boilerplate to start their app. This should include adding support for NEAR to authenticate and link to Ceramic identities (see guides) and have the app deployable on testnet by any developer who needs to use it as a boilerplate to start their app.

Context

Ceramic is a decentralized, censorship-resistant network for managing Web3 data without servers or databases. IDX is a cross-network identity protocol built on Ceramic that enables the sharing of identities, data, and user experiences across networks.

Notes / Tips

The main leap will be the linking of the two technologies rather than the sample app itself (following the guides posted in resources).

NEAR has many keys per AccountId, you can sign and recover the accountId from a signature that came from any access key, but you must check the access keys of the account using near-api-js.

Ceramic will need to establish some link between a user's NEAR AccountId and the ceramic network. If you make this link with an access key vs. accountId, then each time the user logs in/out of your app with NEAR Wallet they will have a different Ceramic link.

A server side example of signature verification can be found here: https://github.com/near-apps/nearbp/blob/8f0a32dc774c68553ff26d1cbdf0592dd7281700/server/middleware/near.js#L23-L59

Client side signing here: https://github.com/near-apps/nearbp/blob/8f0a32dc774c68553ff26d1cbdf0592dd7281700/src/utils/near-utils.js#L28-L36

Resources

https://blog.ceramic.network/add-authentication-with-new-blockchains-in-3id-connect/ https://developers.ceramic.network/reference/typescript/pages/Guides/add-new-blockchain.html https://github.com/ceramicnetwork/CIP/blob/master/CIPs/CIP-7/CIP-7.md https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md https://github.com/ceramicnetwork/js-ceramic/blob/develop/packages/blockchain-utils-linking/src/auth-provider.ts

Acceptance Criteria

Bounty

Approx $ 500 DAI for best projects implementing both technologies!

TrevorJTClarke commented 3 years ago

App Idea:

Dev details:

mattlockyer commented 3 years ago

@TrevorJTClarke nice idea! Would be cool to get an alert if I sign in with my wallet and there is a message that was tagged with my accountId :smile:

TrevorJTClarke commented 3 years ago

@TrevorJTClarke nice idea! Would be cool to get an alert if I sign in with my wallet and there is a message that was tagged with my accountId 😄

@mattlockyer seems reasonable -- guess that would just be a filter to messages assigned to your account. let's call that a stretch goal ;)

ALuhning commented 3 years ago

Alrighty - think I've got this figured out.

App Idea: User Profiles

And, I intend to write it up/do a code walkthrough/provide Github repo of the code.

As of now: -the link between NEAR account and ceramic DID is established/working -in process of building out the schemas/docs and setting up the UI -have put together a ceramic class file that can easily be dropped into another project allowing the near account/did connection via signing/signature

That's my plan - well into it.

TrevorJTClarke commented 3 years ago

Added PR js-ceramic here

Main app repo: https://github.com/TrevorJTClarke/near-ceramic-vue

ALuhning commented 3 years ago

Added a draft CAIP-2 for NEAR - PR here

dzuqe commented 3 years ago

App Idea: A template for creative dapps that require a registry for 3D based content

The template integrates the following tech:

Usage flow:

I'm currently setting up authentication with the NearAuthProvider made by Trevor so as to create a doc on ceramic with the model metadata

Link: https://github.com/rinzlxr/mesh

tahpot commented 3 years ago

If you make this link with an access key vs. accountId, then each time the user logs in/out of your app with NEAR Wallet they will have a different Ceramic link.

@mattlockyer Do you have any thoughts on how to handle this problem due to NEAR having multiple different access keys?

On a related note, I have previously used Ethereum signatures to deterministically generate entropy for an encryption key to store data off-chain. Again, due to multiple access keys I can't see a way to do this with NEAR, but would appreciate if you have any thoughts?

ALuhning commented 3 years ago

Well, finally finished off my take on NEAR/Ceramic integration. Currently setup to run on Testnet - but think this one I'll actually move to MainNet.

High Level Overview:

Using Near-Names as a foundation, extended/revised it to allow someone with a NEAR account to create NEAR personas under that account. Each new account created is registered on a NEAR contract (dids.vitalpointai.testnet) and a Ceramic seed is generated at account creation time which is encrypted and stored in a Ceramic doc for that account. It is also saved to a user's localstorage with end result being a 3ID identifer (DID) that is unique to that NEAR account and that is also recoverable by the NEAR account's seed phrase if need be.

The frontend lets a user login with their NEAR account and create personas (NEAR accounts) that are then accessible from that interface. Each account can have profile information added to it (currently just avatar, name, short bio) - but easily extended.

Because the Personas, schemas, definitions are all Ceramic components, any app can then use Ceramic and the DID registry to lookup a NEAR account name and draw in any information pertaining to it. It's a simple matter of instantiating a Ceramic client and then calling a get function for that user's did.

It makes it easy for people to create and manage all the information they want to provide in a persona in one place and then let apps use that information if they so choose. Updating anything in the Persona will propagate to wherever it is being displayed.

Github Repo: NEAR Personas Demo Video: NEAR Personas Video Demo NEAR Personas (TestNet) App: Near Personas Vital Point AI Tutorial: Building NEAR Personas to Integrate in Your Apps: Decentralized Identity with NEAR Protocol and Ceramic IDX

And that should be everything I promised for the bounty.