From f8f32769820f1c1470dbbf74e3c673af9049cb4f Mon Sep 17 00:00:00 2001 From: Kyle Dewy Date: Fri, 19 Oct 2018 17:29:45 +0200 Subject: [PATCH 1/3] small changes --- README.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index e7b3937f..e143bf01 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,9 @@ [![CircleCI](https://circleci.com/gh/MyBitFoundation/MyBit-Network.tech.svg?style=shield)](https://circleci.com/gh/MyBitFoundation/MyBit-Network.tech) [![Coverage Status](https://coveralls.io/repos/github/MyBitFoundation/MyBit-Network.tech/badge.svg)](https://coveralls.io/github/MyBitFoundation/MyBit-Network.tech) -:factory: A software development kit for the automated machine economy. +A software development kit for the automated machine economy. - Network SDK's are a protocol that allows the creation of decentralised digital assets, funding and trading. It also enables the distribution of revenue generated by assets. These SDK's contain all the functional logic of [MyBit-Go](https://github.com/MyBitFoundation/MyBit-Go.app). - -* For a simple example see [Hello-Network](https://github.com/MyBitFoundation/hello-network) - -* For importing the SDK's as an NPM package see [Network.js](https://github.com/MyBitFoundation/network.js) +The contract SDK is a set of contracts that implement the business logic for the network. The Network SDK is a tool for building Wealth Management Decentralised Applications, without needing in depth blockchain knowledge. For a simple example you can see [Hello-Network](https://github.com/MyBitFoundation/hello-network). To quickly integrate the SDK contracts see [Network.js](https://github.com/MyBitFoundation/network.js). ## Getting Started First install dependencies using [Yarn](https://yarnpkg.com/lang/en/docs/install/#debian-stable): @@ -34,8 +30,8 @@ If successful you should see output similar to below: [4/4] Building fresh packages... Done in 5.69s. ``` - -Then get a local test blockchain running using [Ganache](https://truffleframework.com/ganache) +## Testing +To start local blockchain, [Ganache](https://truffleframework.com/ganache) run: ```bash yarn blockchain @@ -52,14 +48,19 @@ yarn coverage ``` ## [Roles](contracts/roles) -The MYB SDK's have 4 fundamental roles: +To understand the SDK, it's important to understand the 4 fundamental roles on the network: + +### Investor +Investors can contribute ETH or ERC20 tokens to invest in asset orders, receiving asset-tokens in return. To invest they must approve the burner contract. -* Investor `must burn MYB to participate` -* AssetManager `must burn MYB to participate` -* Operator `must be registered by owners` -* Platform Owner(s) +### AssetManager +The assets are managed and created by the AssetManager, who receives a fee for his work and escrows tokens as collateral to investors. The AssetManager must approve the burner contract to burn platform tokens. -Investors can contribute ETH or Erc20 tokens to invest in new asset crowdsales. The assets are managed by the AssetManager, who receives a fee for his work and escrows tokens as collateral to investors. The Operator receives funds from the crowdsale and produces and install the asset. Platform owners can choose how assets are governed, and whether or not a contract upgrade should happen. The platform owner can be a single account or a contract governed by many accounts. +### Operator +The Operator is responsible for producing and installing the asset. They receive 99% of the crowdsale income as a fee for doing so. Platform owners must approve each Operator. + +### Platform Owner(s) +Platform owners can choose how assets are governed, and whether or not a contract upgrade should happen. The platform owner can be a single account or a contract governed by many accounts. Platform owners receive 1% of crowdsale income as a fee. ## Setting Up The Platform @@ -312,7 +313,7 @@ Investors an withdraw income by calling `withdraw()` which updates their persona ``` ## In-Development -:construction: The SDK's are a work in progress and we hope to implement more features such as asset-governance, platform-governance and obfuscated asset authentication. +:construction: The SDK's are a work in progress and we hope to implement more features such as asset-governance, platform-governance and obfuscated asset authentication. ### [Governance](contracts/ownership) We are working on giving investors governance tools to vote for new AssetManagers if the need arises. Voting is based on token holdings and can be accomplished by approving a function call at a particular contract: @@ -361,9 +362,6 @@ GIT_USER= \ yarn run publish-gh-pages ``` -## Live example test-net contracts - - ⚠️ This application is unstable and has not undergone any rigorous security audits. Use at your own risk. MyBit Platform™ CHE-177.186.963 From 91953bc31b09fce925fb97bb12b00f92f860abe6 Mon Sep 17 00:00:00 2001 From: Kyle Dewy Date: Tue, 23 Oct 2018 09:00:19 +0200 Subject: [PATCH 2/3] minor documentation updates --- README.md | 10 +++++----- contracts/database/API.sol | 4 ++-- contracts/ecosystem/AssetGenerator.sol | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e143bf01..132a569c 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,16 @@ yarn coverage ## [Roles](contracts/roles) To understand the SDK, it's important to understand the 4 fundamental roles on the network: -### Investor +#### Investor Investors can contribute ETH or ERC20 tokens to invest in asset orders, receiving asset-tokens in return. To invest they must approve the burner contract. -### AssetManager +#### AssetManager The assets are managed and created by the AssetManager, who receives a fee for his work and escrows tokens as collateral to investors. The AssetManager must approve the burner contract to burn platform tokens. -### Operator +#### Operator The Operator is responsible for producing and installing the asset. They receive 99% of the crowdsale income as a fee for doing so. Platform owners must approve each Operator. -### Platform Owner(s) +#### Platform Owner(s) Platform owners can choose how assets are governed, and whether or not a contract upgrade should happen. The platform owner can be a single account or a contract governed by many accounts. Platform owners receive 1% of crowdsale income as a fee. @@ -313,7 +313,7 @@ Investors an withdraw income by calling `withdraw()` which updates their persona ``` ## In-Development -:construction: The SDK's are a work in progress and we hope to implement more features such as asset-governance, platform-governance and obfuscated asset authentication. +:construction: The SDK's are a work in progress and we hope to implement more features such as asset-governance, platform-governance and obfuscated asset authentication. ### [Governance](contracts/ownership) We are working on giving investors governance tools to vote for new AssetManagers if the need arises. Voting is based on token holdings and can be accomplished by approving a function call at a particular contract: diff --git a/contracts/database/API.sol b/contracts/database/API.sol index 2653bebd..2595e0f8 100644 --- a/contracts/database/API.sol +++ b/contracts/database/API.sol @@ -72,11 +72,11 @@ contract API { return (totalVotes * 100) / TokenView(_assetToken).totalSupply(); } - function getAssetManagerParameterHash(bytes32 _assetID, address _oldBroker, address _newBroker, uint _amount, bool _burn) + function getAssetManagerParameterHash(bytes32 _assetID, address _oldAssetManager, address _newAssetManager, uint _amount, bool _burn) public pure returns (bytes32){ - return keccak256(abi.encodePacked(_assetID, _oldBroker, _newBroker, _amount, _burn)); + return keccak256(abi.encodePacked(_assetID, _oldAssetManager, _newAssetManager, _amount, _burn)); } function getExecutionID(address _executingContract, bytes32 _assetID, bytes4 _methodID, bytes32 _parameterHash) diff --git a/contracts/ecosystem/AssetGenerator.sol b/contracts/ecosystem/AssetGenerator.sol index eef263fd..a520f2f2 100644 --- a/contracts/ecosystem/AssetGenerator.sol +++ b/contracts/ecosystem/AssetGenerator.sol @@ -7,6 +7,7 @@ import "../tokens/erc20/DividendToken.sol"; import "../tokens/distribution/FixedDistribution.sol"; // @title An asset generator contract for onboarding existing real-world assets +// @notice This contract creates ERC20 dividend tokens and give sthem to the _tokenHolders provided // @author Kyle Dewhurst, MyBit Foundation contract AssetGenerator { using SafeMath for uint256; @@ -28,7 +29,7 @@ contract AssetGenerator { external burnRequired returns (bool) { - require (_tokenHolders.length == _amount.length && _tokenHolders.length <= 200); + require (_tokenHolders.length == _amount.length && _tokenHolders.length <= 100); bytes32 assetID = keccak256(abi.encodePacked(msg.sender, _tokenURI)); require(database.addressStorage(keccak256(abi.encodePacked("tokenAddress", assetID))) == address(0)); FixedDistribution assetInstance = new FixedDistribution(_tokenURI, _tokenHolders, _amount); @@ -44,7 +45,7 @@ contract AssetGenerator { external burnRequired returns (bool) { - require (_tokenHolders.length == _amount.length && _tokenHolders.length <= uint8(200)); + require (_tokenHolders.length == _amount.length && _tokenHolders.length <= uint8(100)); address assetGeneratorAddress = database.addressStorage(keccak256(abi.encodePacked("contract", "AssetGenerator"))); bytes32 assetID = keccak256(abi.encodePacked(msg.sender, _tokenURI)); require(database.addressStorage(keccak256(abi.encodePacked("tokenAddress", assetID))) == address(0)); From de31ee7c92e41c63ab102925ba153ff508f47b09 Mon Sep 17 00:00:00 2001 From: Kyle Dewy Date: Tue, 23 Oct 2018 09:03:58 +0200 Subject: [PATCH 3/3] added example code for AssetGenerator --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index 132a569c..04975ae3 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,48 @@ Investors an withdraw income by calling `withdraw()` which updates their persona } ``` +## Onboarding Assets +Using the AssetGenerator contract, users are able to create already funded assets and manage them using the SDK's. + +To create a funded asset call: +```javascript +function createAsset(string _tokenURI, address[] _tokenHolders, uint[] _amount) +external +burnRequired +returns (bool) { + require (_tokenHolders.length == _amount.length && _tokenHolders.length <= 100); + bytes32 assetID = keccak256(abi.encodePacked(msg.sender, _tokenURI)); + require(database.addressStorage(keccak256(abi.encodePacked("tokenAddress", assetID))) == address(0)); + FixedDistribution assetInstance = new FixedDistribution(_tokenURI, _tokenHolders, _amount); + database.setAddress(keccak256(abi.encodePacked("assetManager", assetID)), msg.sender); + database.setAddress(keccak256(abi.encodePacked("tokenAddress", assetID)), address(assetInstance)); + emit LogAssetCreated(assetID, address(assetInstance), msg.sender, _tokenURI); + return true; +} +``` + +If you want the asset to be tradeable on ERC20 exchanges call: +```javascript +function createTradeableAsset(string _tokenURI, address[] _tokenHolders, uint[] _amount) +external +burnRequired +returns (bool) { + require (_tokenHolders.length == _amount.length && _tokenHolders.length <= uint8(100)); + address assetGeneratorAddress = database.addressStorage(keccak256(abi.encodePacked("contract", "AssetGenerator"))); + bytes32 assetID = keccak256(abi.encodePacked(msg.sender, _tokenURI)); + require(database.addressStorage(keccak256(abi.encodePacked("tokenAddress", assetID))) == address(0)); + DividendToken assetInstance = new DividendToken(_tokenURI, assetGeneratorAddress); // Gives this contract all new asset tokens + for (uint8 i = 0; i < _tokenHolders.length; i++) { + assetInstance.mint(_tokenHolders[i], _amount[i]); + } + assetInstance.finishMinting(); + database.setAddress(keccak256(abi.encodePacked("assetManager", assetID)), msg.sender); + database.setAddress(keccak256(abi.encodePacked("tokenAddress", assetID)), address(assetInstance)); + emit LogTradeableAssetCreated(assetID, address(assetInstance), msg.sender, _tokenURI); + return true; +} +``` + ## In-Development :construction: The SDK's are a work in progress and we hope to implement more features such as asset-governance, platform-governance and obfuscated asset authentication.