Coder Social home page Coder Social logo

lit-protocol / relay-server Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 12.0 622 KB

Relay server to facilitate and subsidize some interactions with smart contracts.

TypeScript 89.89% HTML 8.28% CSS 1.12% Shell 0.70% Procfile 0.01%
gasless-transactions relay-server

relay-server's Introduction

Relay Server

โš ๏ธ NOTE: This repo is a work in progress.

This repo was initially made via the instructions from Simple WebAuthn (https://simplewebauthn.dev/docs/advanced/example-project) and provides a fully-functional reference implementation of @simplewebauthn/server and @simplewebauthn/browser.

Relay Server is a server that is centrally run by the Lit Protocol team to facilitate and subsidize some interactions with the Lit Protocol smart contracts.

The Relay Server hosted by the Lit Protocol team currently only interacts with the smart contracts on the Polygon Mumbai network.

If you are to use the contract addresses that are hardcoded into this repo, minting a PKP will work but not storing an encryption condition, as our private key is the only authorized signer to store a condition on behalf of an address.

Running The Server

Prerequisites

  • Install Redis and have a valid connection to it
  • Have access to a valid RPC service endpoint for the network you plan to interact with
  • Have access to a ECDSA private key, with its corresponding wallet containing some funds on the network you plan to interact with

Instructions

Create a .env file at the root of the repo and populate the corresponding environment variables:

  • REDIS_URL
  • PORT
  • LIT_TXSENDER_RPC_URL
  • LIT_TXSENDER_PRIVATE_KEY
  • LIT_DELEGATION_ROOT_MNEMONIC
  • LIT_DELEGATION_USES

Make sure to start your Redis server if you plan to host one locally.

Run yarn install to install the dependencies.

Run yarn start to start the server.


Available Endpoints

Staging instance of the relay server is live at https://relay-server-staging.herokuapp.com. Check out the demo app for an example of how to use the relay server.

Minting PKPs

HTTP Verb Path Description
POST /auth/google Mint PKP for authorized Google account
POST /auth/discord Mint PKP for authorized Discord account
POST /auth/wallet Mint PKP for verified Eth wallet account
GET /auth/webauthn/generate-registration-options Register (i.e., create an account) via supported authenticator
POST /auth/webauthn/verify-registration Verify the authenticator's response
GET /auth/status/:requestId Poll status of minting PKP transaction

Fetching PKPs

HTTP Verb Path Description
POST /auth/google/userinfo Fetch PKPs associated with authorized Google account
POST /auth/discord/userinfo Fetch PKPs associated with authorized Discord account
POST /auth/wallet/userinfo Fetch PKPs associated with verified Eth wallet account
POST /auth/webauthn/userinfo Fetch PKPs associated with WebAuthn credential

*Note: WebAuthn implementation is still a work in progress.


Storing Conditions (only available on Serrano and Cayenne)

HTTP Verb Path Description
POST /store-condition Write encryption conditions to chain

relay-server's People

Contributors

ansonhkg avatar glitch003 avatar hwrdtm avatar joshlong145 avatar jtary avatar sarahzdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

relay-server's Issues

`mintPKP()` stopped working recently

const mintCost = await pkpNft.mintCost(); is failing with the below error

Successfully verified Google account { userId: '???' }
in mintPKP
Unable to mint PKP for given Google account {
  err: Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="mintCost()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.7.0)
      at Logger.makeError (???/lit-protocol-relay-server/node_modules/@ethersproject/logger/lib/index.js:238:21)
      at Logger.throwError (???/lit-protocol-relay-server/node_modules/@ethersproject/logger/lib/index.js:247:20)
      at Interface.decodeFunctionResult (???/lit-protocol-relay-server/node_modules/@ethersproject/abi/lib/interface.js:388:23)
      at Contract.<anonymous> (???/lit-protocol-relay-server/node_modules/@ethersproject/contracts/lib/index.js:395:56)
      at step (???/lit-protocol-relay-server/node_modules/@ethersproject/contracts/lib/index.js:48:23)
      at Object.next (???/lit-protocol-relay-server/node_modules/@ethersproject/contracts/lib/index.js:29:53)
      at fulfilled (???/lit-protocol-relay-server/node_modules/@ethersproject/contracts/lib/index.js:20:58)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    reason: null,
    code: 'CALL_EXCEPTION',
    method: 'mintCost()',
    data: '0x',
    errorArgs: null,
    errorName: null,
    errorSignature: null,
    address: '0x8F75a53F65e31DD0D2e40d0827becAaE2299D111',
    args: [],
    transaction: {
      data: '0xbdb4b848',
      to: '0x8F75a53F65e31DD0D2e40d0827becAaE2299D111',
      from: '0x535b0dABaF59c90EeeBEf272b5F778C5369a1445'
    }
  }
}

I can see transactions stopped 15 hours ago
https://mumbai.polygonscan.com/address/0x535b0dABaF59c90EeeBEf272b5F778C5369a1445

Is 0x8F75a53F65e31DD0D2e40d0827becAaE2299D111 the expected PKP NFT contract address?

pkpNftAddress:
		PKP_NFT_ADDRESS || "0x8F75a53F65e31DD0D2e40d0827becAaE2299D111",

And the contract looks ok at https://chain.litprotocol.com/address/0x8F75a53F65e31DD0D2e40d0827becAaE2299D111

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.