Giter Club home page Giter Club logo

swarm-oracles's Introduction

Introduction

The msgOracle smart-contracts are intended to be the on-chain component (messageToHoneyContract) of SWIP 21.

MsgOracle

The MsgOracle is a smart-contract which inherits functionalities from openzeppelin-solidity/ownable. As such, it can define an owner and limit access to certain function to be only performed by the owner. By reading the events emitted by this smart-contract (in particular: LogNewTTL, LogSetMsgPrice and LogRevertMsgPrice), nodes know the latest value of all message prices in Swarm and be guaranteed that their peers apply the same prices.

Description of public functions

The msgOracle exposes the following functions:

TTL

  • Getter function, which returns the Time To Live (TTL) for the contract. TTL signals to the nodes how long a response from the oracle is guaranteed valid; if a node uses an oracle response which is older than TTL seconds, it is not guaranteed to be correct anymore.

owner

  • Getter function, which return the current owner of the contract.

newTTL

  • Sets a new Time To Live (TTL). TTL can only be updated after TTL seconds after it was set.
  • Stores the previous value of TTL .
  • Stores when the function was called.
  • Emits a LogNewTTL(uint256 TTL) event on which nodes can listen to be informed on changes in TTL.
  • only callable by owner

setMsgPrice

  • informs the node about a new price for a particular swarmMsg, in effect from a certain date (validFrom)
  • requires validFrom to be at least TTL seconds in the future. If TTL has been recently updated (not longer than the old value of TTL seconds ago), we use the old value of TTL.
  • Emits a LogSetMsgPrice(bytes32 indexed swarmMsg, uint256 price, uint256 validFrom) event.
  • only callable by owner

revertMsgPrice

  • informs the node to ignore a previous emitted LogSetMsgPrice event with the same arguments as the LogRevertMsgPrice(bytes32 indexed swarmMsg, uint256 price, uint256 validFrom) event, emitted by this function.
  • only callable by owner

renounceOwnership

  • Set's the ownership of this smart-contract to the 0 address, which will render all functionalities of this smart-contract forever useless.
  • emits an OwnershipTransferred(address indexed previousOwner, address indexed newOwner) event.
  • only callable by owner

transferOwnership

  • Set's the ownership of this smart-contract to another address. Meant for updating the governance around the oracle.
  • emits an OwnershipTransferred(address indexed previousOwner, address indexed newOwner) event.
  • only callable by owner

swarm-oracles's People

Contributors

eknir avatar

Watchers

James Cloos 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.