Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ethersphere/swarm-oracles
obsolete - This repository holds the smart-contracts for on-chain oracles, used for updating global variables in the Swarm network
https://github.com/ethersphere/swarm-oracles
obsolete
Last synced: about 2 months ago
JSON representation
obsolete - This repository holds the smart-contracts for on-chain oracles, used for updating global variables in the Swarm network
- Host: GitHub
- URL: https://github.com/ethersphere/swarm-oracles
- Owner: ethersphere
- Created: 2019-10-22T14:18:42.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T00:43:12.000Z (almost 2 years ago)
- Last Synced: 2023-08-19T00:11:02.113Z (over 1 year ago)
- Topics: obsolete
- Language: JavaScript
- Homepage:
- Size: 471 KB
- Stars: 4
- Watchers: 7
- Forks: 4
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction
The msgOracle smart-contracts are intended to be the on-chain component (`messageToHoneyContract`) of [SWIP 21](https://github.com/ethersphere/SWIPs/blob/bddd78a24ae4c036cb63f79578cf26c2ec9195a9/SWIPs/swip-21-message_to_honey.md).# MsgOracle
The MsgOracle is a smart-contract which inherits functionalities from [openzeppelin-solidity/ownable](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/ownership/Ownable.sol). 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.## Tests
This is a regular truffle project. You can either use `truffle test` (if installed) or `npm test` which will use a locally installed truffle.
```sh
npm install
npm test
```## Go-bindings
To generate go bindings use
```sh
npm run abigen
```This will generate the bindings in the `bindings/` directory. Suitable versions of `solc` and `abigen` have to be installed for this to work.
Alternatively this can also be done through docker:```sh
docker build -t swarm-oracles .
docker run -v $(pwd)/bindings:/oracles/bindings swarm-oracles npm run abigen
```In addition to the file from `abigen` this will also generate a go file that includes the runtime bytecode.
## 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`