Giter Club home page Giter Club logo

smart-contracts's Introduction

Monerium

GitHub GitHub release Build Status

The Monerium e-money platform offers programmable fiat money on blockchains, an indispensable building block for the nascent blockchain economy.

Tokens

Ethereum

EUR GBP ISK USD
EUR
eur.monerium.eth
GBP
gbp.monerium.eth
ISK address
isk.monerium.eth
USD address
usd.monerium.eth

Polygon Pos

EUR GBP ISK USD
EUR
Polygon.Pos.EUR
GBP
Polygon.Pos.GBP
ISK address
Polygon.Pos.ISK
USD address
Polygon.Pos.USD

Token Design

Four cooperating Ethereum smart-contracts are deployed for each e-money currency token that is ERC20 compliant.

  • Token Frontend: This contract implements the ERC20 token standard and provides a permanent Ethereum address for the token system. The contract only exposes the required ERC20 functionality to the user and delegates all of the execution to the controller.
  • Controller: The controller is responsible for the business logic. The controllers are further separated by the functionality they provide into; StandardController, MintableController and SmartController.
  • Token Storage: Storage of e-money token ledger.
  • Validator: The validator can be used by the controllers to approve and validate transactions before they are made.

token system design

Using this design we're able to upgrade the business logic, to fix bugs or add functionality, while providing a fixed address on the blockchain and permanent access to the token bookkeeping.

Implementation

The token system is implemented using Solidity, the most widely used high level language targeting the EVM. We build upon community vetted libraries where possible to minimize the risk of bugs.

Additional functionality has been implemented in MintableTokenLib.sol and SmartTokenLib.sol. This includes minting and burning tokens and defining validators who determine whether token transactions are valid or not.

Functionality which requires authorization is protected by OpenZeppelin's implementation of the Ownable contract. The management of the private key of the owner is very simple at the moment but for v1.0.0 a multi-signature account or a simple DAO will be used.

Solidity libraries

Libraries in Solidity provide the means to deploy an implementation once as a compiled byte code but without an execution context (storage). Contracts deployed subsequently can then be statically linked to the library.

Our token system takes advantage of this feature to save gas deploying multiple tokens. It can also be argued that sharing audited libraries between contracts can reduce the risk of bugs and worst case ease the replacement of a buggy implementation.

Building

  1. Clone the repository

    git clone --recursive https://github.com/monerium/smart-contracts.git
    cd smart-contracts
  2. Install dependencies

    yarn install
  3. Run truffle

    npx truffle develop
  4. Compile token system

    truffle(develop)> compile --all
  5. Deploy

    truffle(develop)> migrate --reset
  6. Run test suite

    truffle(develop)> test

Development

To ease the development, deployment and interaction with the token system we're using truffle.

Truffle's ganache simulates full client behavior and makes developing Ethereum applications much faster while Truffle is a development environment, testing framework and asset pipeline for Ethereum.

Development happens on the master branch and we use Semantic Versioning for our tags. The first pre-release version deployed on a non-testrpc blockchain is v0.7.0.

Deployment

# npx truffle migrate [--network <name>]
Contract Mainnet (v1.0.3) Polygon-Pos (v1.10.0) Ropsten (v1.0.3) Kovan (v1.0.3) Rinkeby (v1.0.3) Mumbai
EUR 0x3231cb76718cdef2155fc47b5286d82e6eda273f 0x18ec0A6E18E5bc3784fDd3a3634b31245ab704F6 0x0ae91c2b9e31e92871129117d908b0963c054048 0x9b8fd8fcfaa2438d11e7ed77d5afb6c2e1044b37 0x25c13fc529dc4afe4d488bd1f2ee5e1ec4918e0b 0xCF487EFd00B70EaC8C28C654356Fb0E387E66D62
GBP 0x7ba92741bf2a568abc6f1d3413c58c6e0244f8fd 0x75792CBDb361d80ba89271a079EfeE62c29FA324 0xd9979346224e7b147caddf399b56357e20d3e67c 0xe28884ed5bd43e3f9f1dd733d254c9f5c6f983d2 0x01df10e345d0364d3a5b8422a66af6305803bd1e 0x890e629d2728f470811adDc84990de9f5e91bC72
ISK 0xc642549743a93674cf38d6431f75d6443f88e3e2 0xf1bBf27A9D659D326efBfa5D284EBaeFB803983D 0x80b02ef56cbbc542f0ce89ad1d2a680244da9a63 0x39ad1ad871787ba4b3df5b8ac3d81b2c9b7c6290 0x0c9d7a0d8bf4bc9d15f577bbf650ebc8044a71db 0x3fC9C5725eE369d6DDf08481ee5B31BA3c8e3D91
USD 0xbc5142e0cc5eb16b47c63b0f033d4c2480853a52 0x64E97c1a6535afD4a313eF46F88A64a34250B719 0x3781dcdd60e006e33b664dce0d6be934f0a139c8 0x57724f65b3f914de7820c6f76b2099fa3a90f509 0x09c0a236e1227500f495cb0731c4af69b49639a5 0xcCA6b920eebFf5343cCCf386909Ec2D8Ba802bdd

The token addresses can be resolved using ENS in compatible wallets.

Contract Mainnet Rinkeby
EUR eur.monerium.eth
GBP gbp.monerium.eth
ISK isk.monerium.eth monerium.test
USD usd.monerium.eth

Unit tests

The token system ships with JavaScript unit tests.

# make test

Code coverage

Code coverage for the token system can be checked with solidity-coverage.

# make coverage

Code coverage

License

Copyright 2019 Monerium ehf.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

smart-contracts's People

Contributors

gislik avatar kristenpire avatar arnigudj avatar hjortur avatar kerma avatar einaralex avatar siibars 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.