Coder Social home page Coder Social logo

smartcontracts's Introduction

Base Smart Contracts

We use OpenZeppelin smart contracts as base for some of Papyrus smart contracts. Currently commit 725ed40a57e8973b3ae6e2f39f9c887d0056ca39 is used.

Also we use MultiSigWalletWithDailyLimit implementation from Gnosis for Papyrus wallets. Commit c23be004ad993248281805303278abe14c410c8d is used.

SafeMath.sol

Implements helper functions which make simple arithmetic operations with overflow checking. Based on OpenZeppelin SafeMath smart contract. Note that functions throw when overflow is detected.

Functions

  • mul - safely multiplies specified values. Has following arguments:
    • a (uint256) - first argument for the arithmetic operation.
    • b (uint256) - second argument for the arithmetic operation.
  • div - safely divides specified values. Has following arguments:
    • a (uint256) - first argument for the arithmetic operation.
    • b (uint256) - second argument for the arithmetic operation.
  • sub - safely substracts specified values. Has following arguments:
    • a (uint256) - first argument for the arithmetic operation.
    • b (uint256) - second argument for the arithmetic operation.
  • add - safely adds specified values. Has following arguments:
    • a (uint256) - first argument for the arithmetic operation.
    • b (uint256) - second argument for the arithmetic operation.

Ownable.sol

Has an owner address and provides basic authorization control functions, this simplifies the implementation of "user permissions". Based on OpenZeppelin Ownable smart contract.

Events

  • OwnershipTransferred - arises when ownership is transferred. Has following arguments:
    • previousOwner (address) - address of previous owner.
    • newOwner (address) - address of new owner.

Functions

  • transferOwnership - transfers ownership to new address. Can be used only by current owner. Has following arguments:
    • newOwner (address) - address of new owner.

Modifiers

  • onlyOwner - fails if sender is not owner.

ERC20.sol

Just describes standard ERC20 interface. Information about ERC20 standard can be found at ethereum/EIPs#20.

StandardToken.sol

Implements standard ERC20 token. All Papyrus token smart contracts should be inherited from this StandardToken smart contract.

Papyrus Smart Contracts

PapyrusPrototypeToken.sol

Implements ERC20 token. It is inherited from StandardToken and Ownable smart contracts.

It has hardcoded name Papyrus Prototype Token and symbol PRP with 18 decimals (just like ETH and many other tokens).

PRP token is not transferable from the creation. This can be changed later using function setTransferable() by owner of smart contract.

Smart contract has public variable totalCollected. It accumulates amount of received USD during Token Generation Event. To calculate this value in USD when calling mint function we specify _priceUsd value used at moment of participation. Value 0 can be used for tokens that are minted not as part of Token Generation Event (tokens minted for bounty, etc.). Implementation minting tokens is based on MintableToken smart contract from OpenZeppelin, so _priceUsd argument and totalCollected calculation logic are only differences against it.

Events

  • Mint - arises when tokens are minted. Has following arguments:
    • to (address) - address which gets minted tokens.
    • amount (uint256) - amount of minted tokens.
    • priceUsd (uint256) - price for 1 token in USD at moment of participation.
  • MintFinished - arises when minting tokens is over. It is not possible to mint tokens after event is happened.
  • TransferableChanged - arises when ability to transfer tokens by holders is changed. Has following arguments:
    • transferable (bool) - new transferable value.

Functions

  • mint - mints (creates) tokens and store them at specified address. Can be used only by owner until minting is finished. Has following arguments:
    • _to (address) - address which gets minted tokens.
    • _amount (uint256) - amount of minted tokens.
    • _priceUsd (uint256) - price for 1 token in USD. Please note that 18 decimals value is expected. For example, if price for 1 token is $0.8 then value 800000000000000000 (0.8 * 10^18) should be used. Since 18 decimals is used for this value (the same amount of decimals that used for ETH), standard web3 functions can be used to calculate this value, for example web3.toWei(0.8, 'ether').
  • finishMinting - finishes minting and denying further minting tokens. Can be used only by owner until minting is finished.
  • setTransferable - changes ability to transfer tokens by holders. Can be used only by owner. Has following arguments:
    • _transferable (bool) - token becomes transferable when true and not transferable when false.

smartcontracts's People

Contributors

vlasenkoandrey avatar wardencliffe avatar ltalal avatar

Watchers

James Cloos avatar

Forkers

drakevonduck

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.