Git Product home page Git Product logo

trustus's Introduction

Trustus

Trust-minimized method for accessing offchain data onchain. No, it's not a joke project.

just trust us bro

Introduction

Suppose we have:

  • A server with an API that provides some useful information (e.g. the weather in Philedelphia today)
  • A smart contract that wants to access said information from the server

How can we implement it? How can we let the smart contract access the offchain data from the server?

One way to do it is to use Chainlink to make an HTTP GET request to the server, but this is terrible!

  • We need to rely on Chainlink nodes, whose level of centralization is rather controversial
  • We need to hold LINK tokens in the contract and pay the nodes for each request
  • We need to implement a callback pattern, which is asynchronous and messy

Trustus offers a superior solution that is trust-minimized. Trustus-powered contracts do not rely on any third-party network of nodes, nor do they need to make payments for the requests or implement a callback pattern. The only centralized & trusted component is the server, which has to be trusted anyways, hence the term "trust-minimized".

How is this achieved? Two caveats:

  1. The server must implement the specific standard used by Trustus to format the data packet, as well as provide an ECDSA signature that verifies the data packet originated from the trusted server.
  2. The smart contract should take in the signed data packet as an input of the function that requires the offchain data and verify its validity. The contract should also keep track of which addresses are trusted to sign the data packets.

The userflow of a call to a Trustus-power smart contract looks like this:

  1. The user makes a request to the server to fetch the desired offchain data.
  2. The server returns the data packet as well as a signature signed using the server's public key, which should already registered as trusted by the smart contract.
  3. The user calls the smart contract, providing the data packet & signature as input.
  4. The smart contract verifies & consumes the data packet, and uses the offchain data during the call.

Installation

To install with DappTools:

dapp install zeframlou/trustus

To install with Foundry:

forge install zeframlou/trustus

Local development

This project uses Foundry as the development framework.

Dependencies

make install

Compilation

make build

Testing

make test

trustus's People

Contributors

zeframlou avatar han1ue avatar

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.