Skip to content

monerium/smart-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monerium

GitHub release

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

Monerium EMI is an Electronic Money Institution, currently the only financial entity licenced to issue e-money on blockchains. Electronic money (e-money) has been recognized in the European Economic Area (EEA) as a digital alternative to cash since 2000 when the first e-money Directive was introduced. Monerium e-money is 1:1 backed in fully segregated, unencumbered, high-quality liquid assets and unconditionally redeemable on demand. Read more about e-money here.

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

Gnosischain

EUR GBP ISK USD
EUR
Gnosischain.EUR
GBP
Gnosischain.GBP
ISK token
Gnosischain.ISK
USD token
Gnosischain.USD

Test tokens

For the innovators, product builders, and other curious minds we've opened up a sandboxed version of our system that is connected to the Rinkeby test network. Play around with our money in a safe environment to understand how this fits into your platform. Go to sandbox.

Please fill out the "Partner with Monerium" form on monerium.com to get test money for the Ropsten or Kovan test networks.

Contract Ethereum Sepolia Polygon Amoy Gnosischain Chiado
EUR 0xd58C5Db52B5B3Eb24EE38AF287d2cb0F424172A5 0xF011267f494Cf371CCd8016927723065072615A9 0xb106ed7587365a16b6691a3D4B2A734f4E8268a2
GBP 0x0D43441eA7C6D684A74EA63958A7ab5C2831959d 0xf649DC9b2DF316BA82B1A35b507DEA405B9B4D34 0xf649DC9b2DF316BA82B1A35b507DEA405B9B4D34
ISK 0x771c595DAA3bE7389ac768001Dff1A7b82c700b3 0x8bA8662a7C5C6Be4B4ad7049c5DbF59aaCC2cf1e 0x2fADa6C9AEaa03BBaEE07F4761FB30C097367dC4
USD 0x8bA8662a7C5C6Be4B4ad7049c5DbF59aaCC2cf1e 0x890e629d2728f470811adDc84990de9f5e91bC72 0xA8c6bD0b147f9c612c43629EAD1784aa57ED60E7

Token integration

We at Monerium er really exited to talk to all developers and builders that want to use money in their applications. Go to monerium.com and fill out the "Partner with Monerium" form and our expert staff will be available to help you every step of the way, from implementation to ongoing operations.

Each token has the following ERC20 and ERC677 methods available to integrate with your application.

contract Euro {

  // Transfers tokens [ERC20].
  transfer(to, amount)

  // Transfers tokens from a specific address [ERC20].
  transferFrom(from, to, amount)

  // Approves a spender [ERC20].
  approve(spender, amount)

  // Transfers tokens and subsequently calls a method
  // on the recipient [ERC677].
  transferAndCall(to, amount, data)

  // Returns the total supply.
  totalSupply()

  // Returns the number tokens associated with an address.
  balanceOf(who)

  // Returns the allowance for a spender
  allowance(owner, spender)
}

ERC20: Approve and transfer from

The user gives your smart contract the right to take the money by itself from their address using the approve method. Once approved, your contract can call the transferFrom method in the Monerium contract and transfer money from the address.

ERC677: Transfer and call

transferAndCall transfers money and calls the receiving contract's onTokenTransfer method with additional data and triggers an event Transfer.

ERC2612: Permit

ERC2612 introduces a method for token holders to approve spenders with a signed permission, streamlining transactions without on-chain approve calls. This functionality enables efficient gas-less approvals, leveraging EIP-712 signed messages for secure delegation of spending rights.

The Permit function, while not directly accessible through the Token interface, can be invoked via the controller.

For a step-by-step implementation guide, refer to the detailed tutorial in Permit Function Documentation.

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>]

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

Smart contract audit

The smart contracts were audited by Ackee Blockchain Security. The report is available here.

License

Copyright 2023 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.