Tokenizer Contracts Prototype – 标记器契约原型区块链毕设代写

区块链毕设代写本文提供国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,Tokenizer Contracts Prototype – 标记器契约原型区块链毕设代写 是一篇很好的国外资料

Tokenizer Contracts Prototype

AMPnet Crowdfunding Platform v1.0 written in Solidity language.

Contract types

There are 4 different contract implementations:

  • Issuer.sol
  • Asset.sol
  • CfManagerSoftcap.sol
  • PayoutManager.sol

Dynamics between these contracts is shown in the image below and then explained in the detail in the next section.

Tokenizer Contracts Prototype - 标记器契约原型

Features

  • Issuer creation (Issuer.sol)
    • Issuer is an organizational unit representing a collection of multiple assets. Each issuer is described by one Issuer.sol contract instance deployed on the chain.
    • Issuer has only one owner (of type address)
    • Each asset belongs to one issuer
    • Think of Issuer being a company owning multiple assets in the real world, and each of those assets has been tokenized and mapped to the ERC20 token
    • Issuer holds the mapping of the whitelisted wallets. This is important if the Asset token is only allowed to be transferred between whitelisted/approved wallets. This is also important if the Asset tokens are being sold at the crowdfunding campaign where only whitelisted investors are allowed to invest.
    • Issuer can be configured with following parameters:
      • stablecoin address -> address of the stablecoin to be accepted for the investments (if one the Asset tokens created for the Issuer is sold at the crowdfunding campaign)
      • wallet approver address -> address with the rights to whitelist or suspend wallets. Can be configured to one of AMPnet addresses to automate wallet whitelisting after users have successfully finished the KYC process for example. Issuer creators can provide other addresses here if they want to have a full control and handle user whitelisting by themselves.
      • issuer info -> info ipfs hash describing one issuer (updatable by the owner)
  • Asset creation (Asset.sol)
    • Asset is an ERC20Snapshot contract. Snapshottable to support rewarding token holders at any point in time regardless of the fact that token shareholder structure might change later on.
    • Each issuer is described by one Asset.sol contract instance deployed on the chain.
    • Asset is of fixed supply.
    • No one can create or destroy supply.
    • Once the token has been created, the owner/creator is holding the 100% of the supply. Owner can then manage tokens using one of the Manager contracts.
    • Asset can be configured with the following parameters during the creation:
      • issuer address -> address of the issuer whose member this Asset will become
      • initial token supply -> number of the tokens to be created. Not changeable afterwards.
      • asset info -> name, symbol, info ipfs hash (updatable by the owner)
      • whitelist required for the token transfer -> flag to limit the asset transfers. If set to true only the addresses whitelisted by the superior issuer can. If set to false, asset will work as any other ERC20 token, freely tradable between any two addresses.
  • Crowdfunding Campaigns (CfManagerSoftcap.sol)
    • Crowdfunding Campaigns are created by deploying CfManagerSoftcap.sol contract and transferring any amount of the Asset tokens to the deployed contract address. CfManagerSoftcap then handles the investors, and distributes tokens based on the investment amount.
    • Each crowdfunding campaign is described by one CfManagerSoftcap.sol contract instance deployed on the chain.
    • Crowdfunding campaign can be configured with following parameters:
      • asset address -> address of the asset whose tokens will be sold during the crowdfunding campaign
      • token price -> price per token expressed as integer with 4 decimal places precision encoded in the value. For example, value 10000 represents the price of $1 (dollar if USDC token is configured for the Issuer as an accepted payment method, but can be any other coin). The value 123456 representes the price of $12.3456 per token.
      • soft cap -> minimum amount of funds to be raised for the campaign to be considered successful. Campaign owners can finalize campaign only if this amount has been reached.
      • whitelist required flag -> if set to true, only wallets whitelisted by the superior issuer can invest and be part of the crowdfunding campaign. Value false will allow anyone to invest.
    • After crowdfunding campaign has been created (contract deployed), Asset token owner must simply call the ERC20 transfer and send any amount of the tokens he is willing to sell to the address of the newly created CrowdfundingManager contract instance. There is an optional step before the token transfer, Issuer owner has to whitelist the CrowdfundingManager contract but this is only the case if the Asset token has been configured to only be transferable between whitelisted wallets.
    • Asset owner can’t withdraw tokens sent to the crowdfunding campaign, but can send more of his tokens to the same campaing to increase the amount of the tokens to be sold, if he wishes to do so.
    • Investors can invest in the active crowdfunding campaign by executing the two steps:
      1. call approve(investmentAmount) function to approve CrowdfundingManager contract to spend their funds. Approve function is called on the stablecoin contract defined as the accepted payment method by the Asset token’s belonging Issuer.
      2. call invest(investmentAmount) which will result in CrowdfundingManager contract taking investor’s investmentAmount funds, and storing investment details for the investor so he can claim bought tokens if the campaign gets finalized successfully by the campaign owner.
    • Investors are allowed to cancel their investment only if the CrowdfundingManager contract was not finalized by the campaign creator (see below). Investors can cancel the investment by calling the cancelInvestment() function which will in turn reset their claimable Asset tokens amount and refund the stablecoin they invested back to their wallets.
    • CrowdfundingManager owner must eventually call one of two functions on the CrowdfundingManager contract:
      • finalize() -> only callable by the campaign creator if the campaign has reached the soft cap. This will close the campaign, so new investors can no longer invest, and existing investors can finally claim their tokens by calling the claim() function. finalize() will also transfer all of the funds raised from the crowdfunding manager contract to the campaign owner’s wallet, and transfer all of the remaining (unsold) asset tokens back to the owner’s wallet.
      • cancelCampaign() -> only callable by the campaign creator if the campaign hasn’t been finalized before. By canceling the campaign, all of the Asset tokens to be sold are returned to the campaign owner’s wallet, and new investments are no longer possible. Existing investors can cancel their investments by calling the cancelInvestment() function. Investment cancellation can be triggered by the investor at all times but not if the camapign has been finalized.
  • Asset Token Holder Rewards (PayoutManager.sol)
    • Asset is actaully an ERC20Snapshot instance with the possibility of taking the token ownership structure snapshots at any point in time. Every snapshot taken on the Asset contract will get its unique snapshotID (auto increment integer where first snapshot is assigned with id=1).
    • PayoutManager.sol contract can use the snapshot mechanism for the underlying asset to create and hold stablecoin rewards for Asset token holders at given snapshot ID.
    • To distribute for example some amount of USDC to the Asset token holders proportional to the current Asset ownership structure, one must execute three steps:
      1. deploy PayoutManager.sol for given Asset token
      2. approve the PayoutManager contract instance to spend some amount of USDC from payer’s wallet
      3. call the createPayout(amount) function on the Payout Manager which will in turn transfer USDC amount to the payout manager contract and create the snapshot on underlying asset to give rights to all the token holders at that snapshotID to claim their share of the received USDC funds.
    • Asset token holders with rights to claim rewards at given snapshotID (so all the wallets with >0 asset token amount at that snapshotID moment) can claim the funds by calling the release() function on the payot manager contract

Crowdfunding Campaign scenarios

Crowdfunding campaign creation includes 4 steps:

  1. Asset (ERC20Snapshot) has to be created with fixed supply and address of the belonging Issuer instance. Asset creator must decide on the supply upfront and cannot change it afterwards. Asset creator becomes a 100% holder of this token.

  2. Asset creator deploys CfManagerSoftcap.sol by providing the address of previously created token.

  3. *Issuer has to whitelist this crowdfunding campaign (issuer owner, asset owner, and cfManager owner can all be the same address). This step can be skipped if the Asset is created as a freely tradable token (see more in features). If asset allows only whitelisted addresses to take part in transfer actions then the CfManager contract also has to be whitelisted by calling the approveCampaign(cfManagerInstanceAddress) function on the Issuer instance.

  4. Asset creator transfers amount of tokens he is willing to sell to the address of the CfManager contract created in the step 2.

Different crowdfunding campaign models may be created by providing different constructor parameters for CfManagerSoftcap.sol in the step 2 above. Some of them are listed here:

-> softCap can be set to 0, so any amount of tokens can be sold before campaing manager chooses to finalize the campaign. This can be useful for example for charity fundraising where any amount of funds collected is useful. The rest of the tokens (unsold ones) are returned to the token owner after campaign finalization.

-> softCap can be set to be equal the total value of tokens being sold, this way the campaign is only successful and can be finalized if all of the tokens are sold.

-> softCap can be set to somewhere between 0 and the total value of the tokens being sold. This way we have a campaign with softCap (predefined param) and hardCap (total value of tokens being sold) params where campaign owner can finalize() the campaign if the funds raised are anywhere between [softCap, hardCap].

-> campaign manager can refill cfManager contract with his remaining tokens if the sale is going good, by simply transferring more tokens to the address of the crowdfunding manager contract

Factories

Each of the 4 different contracts can and will be deployed by calling its factory contract’s create() method. That way, we can have official factory contracts deployed on the chain at known addresses and we can be sure that all the contracts created this way weren’t tampered with. Every factory holds addresses of all the instances ever created by calling their create() function. It’s easy to check for the contract with address A if it was created by an official factory or not.

List of factory contracts:

  • AssetFactory.sol
  • IssuerFactory.sol
  • CfManagerSoftcapFactory.sol
  • PayoutManagerFactory.sol

Known issues

  • PayoutManager must take into account big token holders when distributing revenue based on some given snapshotID. For example, if token owner has sold 80% of the supply, he is still owner of the remaining 20%. But he doesn’t want to payout revenue to himself, he only wants to distribute rewards to the investors. One possible solution is to initialize the PayoutManager contract instance with the array of big addresses, and these are then taken into account when calculating the share in release(payoutID) function. This solution will be implemented if no better option is found.

transferable asset release candidate


代币商合同原型

AMPnet众筹平台v1.0以Solidity语言编写

合同类型

有4种不同的契约实现:

  • 发行人.sol
  • 资产.sol
  • 支付管理人.sol创建(Issuer.sol)发行人是一个组织单位,代表多个资产的集合。每个发行人由部署在链上的一个issuer.sol合同实例描述。发行人只有一个所有者(地址类型)。每个资产属于一个发行人。如果发行人是一家在现实世界中拥有多个资产的公司,那么这些资产中的每一个都已标记化并映射到ERC20标记。发行人持有白名单钱包的映射。如果仅允许在白名单/批准的钱包之间转移资产令牌,这一点很重要。如果在众筹活动中出售资产代币,这一点也很重要。在众筹活动中,只有白名单上的投资者才允许投资。发卡机构可以配置以下参数:stablecoin地址->接受投资的stablecoin地址(如果在众筹活动中出售了为发行人创建的资产代币之一)钱包批准人地址->具有白名单或挂起钱包权限的地址。例如,可以将配置为AMPnet地址之一,以便在用户成功完成KYC过程后自动将钱包列入白名单。如果发卡机构创建者想要完全控制并自行处理用户白名单,他们可以在此处提供其他地址。发卡机构信息->信息ipfs散列描述一个发行人(可由所有者更新)
  • 发行人是一个组织单位,代表多个资产的集合。每个发行人由部署在链上的一个issuer.sol合同实例描述

这些契约之间的动态如下图所示,然后在下一节中详细解释

Tokenizer Contracts Prototype - 标记器契约原型

特征

  • 发行人只有一个所有者(地址类型)
  • 资产是固定供应的
  • Crowdfunding Campaigns (CfManagerSoftcap.sol)
    • Crowdfunding Campaigns are created by deploying CfManagerSoftcap.sol contract and transferring any amount of the Asset tokens to the deployed contract address. CfManagerSoftcap then handles the investors, and distributes tokens based on the investment amount.
    • Each crowdfunding campaign is described by one CfManagerSoftcap.sol contract instance deployed on the chain.
    • Crowdfunding campaign can be configured with following parameters:
      • asset address -> address of the asset whose tokens will be sold during the crowdfunding campaign
      • token price -> price per token expressed as integer with 4 decimal places precision encoded in the value. For example, value 10000 represents the price of $1 (dollar if USDC token is configured for the Issuer as an accepted payment method, but can be any other coin). The value 123456 representes the price of $12.3456 per token.
      • soft cap -> minimum amount of funds to be raised for the campaign to be considered successful. Campaign owners can finalize campaign only if this amount has been reached.
      • whitelist required flag -> if set to true, only wallets whitelisted by the superior issuer can invest and be part of the crowdfunding campaign. Value false will allow anyone to invest.
    • After crowdfunding campaign has been created (contract deployed), Asset token owner must simply call the ERC20 transfer and send any amount of the tokens he is willing to sell to the address of the newly created CrowdfundingManager contract instance. There is an optional step before the token transfer, Issuer owner has to whitelist the CrowdfundingManager contract but this is only the case if the Asset token has been configured to only be transferable between whitelisted wallets.
    • Asset owner can’t withdraw tokens sent to the crowdfunding campaign, but can send more of his tokens to the same campaing to increase the amount of the tokens to be sold, if he wishes to do so.
    • Investors can invest in the active crowdfunding campaign by executing the two steps:
      1. call approve(investmentAmount) function to approve CrowdfundingManager contract to spend their funds. Approve function is called on the stablecoin contract defined as the accepted payment method by the Asset token’s belonging Issuer.
      2. call invest(investmentAmount) which will result in CrowdfundingManager contract taking investor’s investmentAmount funds, and storing investment details for the investor so he can claim bought tokens if the campaign gets finalized successfully by the campaign owner.
    • Investors are allowed to cancel their investment only if the CrowdfundingManager contract was not finalized by the campaign creator (see below). Investors can cancel the investment by calling the cancelInvestment() function which will in turn reset their claimable Asset tokens amount and refund the stablecoin they invested back to their wallets.
    • CrowdfundingManager owner must eventually call one of two functions on the CrowdfundingManager contract:
      • finalize() -> only callable by the campaign creator if the campaign has reached the soft cap. This will close the campaign, so new investors can no longer invest, and existing investors can finally claim their tokens by calling the claim() function. finalize() will also transfer all of the funds raised from the crowdfunding manager contract to the campaign owner’s wallet, and transfer all of the remaining (unsold) asset tokens back to the owner’s wallet.
      • cancelCampaign() -> only callable by the campaign creator if the campaign hasn’t been finalized before. By canceling the campaign, all of the Asset tokens to be sold are returned to the campaign owner’s wallet, and new investments are no longer possible. Existing investors can cancel their investments by calling the cancelInvestment() function. Investment cancellation can be triggered by the investor at all times but not if the camapign has been finalized.
  • Asset Token Holder Rewards (PayoutManager.sol)
    • Asset is actaully an ERC20Snapshot instance with the possibility of taking the token ownership structure snapshots at any point in time. Every snapshot taken on the Asset contract will get its unique snapshotID (auto increment integer where first snapshot is assigned with id=1).
    • PayoutManager.sol contract can use the snapshot mechanism for the underlying asset to create and hold stablecoin rewards for Asset token holders at given snapshot ID.
    • To distribute for example some amount of USDC to the Asset token holders proportional to the current Asset ownership structure, one must execute three steps:
      1. deploy PayoutManager.sol for given Asset token
      2. approve the PayoutManager contract instance to spend some amount of USDC from payer’s wallet
      3. call the createPayout(amount) function on the Payout Manager which will in turn transfer USDC amount to the payout manager contract and create the snapshot on underlying asset to give rights to all the token holders at that snapshotID to claim their share of the received USDC funds.
    • Asset token holders with rights to claim rewards at given snapshotID (so all the wallets with >0 asset token amount at that snapshotID moment) can claim the funds by calling the release() function on the payot manager contract

众筹活动场景

众筹活动创建包括4个步骤:

  1. 必须使用所属发行人实例的固定供应和地址创建资产(ERC20Snapshot)。资产创建者必须事先决定供应,并且不能在事后更改。资产创建者成为此令牌的100%持有人

  2. 资产创建者通过提供先前创建的令牌的地址来部署CfManagerSoftcap.sol

  3. *发行人必须将此众筹活动列入白名单(发行人所有者、资产所有者和cfManager所有者可以是同一地址)。如果资产被创建为可自由交易的代币,则可以跳过此步骤(请参阅功能中的更多内容)。如果asset只允许白名单地址参与传输操作,那么还必须通过调用发卡机构实例上的approveCampaign(cfManagerInstanceAddress)函数来白名单CfManager合同

  4. 资产创建者将其愿意出售的代币数量转移到第2步中创建的CfManager合同地址。

通过在上述第2步中为CfManagerSoftcap.sol提供不同的构造函数参数,可以创建不同的众筹活动模型。此处列出了其中一些内容:

->softCap可以设置为0,因此在campaing manager选择完成活动之前,可以出售任意数量的代币。例如,在慈善筹款活动中,收集到的任何金额的资金都是有用的。活动结束后,剩余的令牌(未售出的令牌)将返还给令牌所有者

->softCap可以设置为等于正在出售的代币的总价值,这样,只有当所有代币都售出时,活动才会成功,并且可以最终确定

->softCap可以设置为介于0和正在出售的代币总值之间的某个位置。这样,我们就有了一个包含softCap(预定义参数)和hardCap(出售代币的总价值)参数的活动,如果筹集的资金介于[softCap,hardCap]之间,活动所有者可以在其中完成()活动

->如果销售情况良好,活动经理只需将更多代币转移到众筹经理合同的地址,就可以用剩余的代币重新填充cfManager合同

已知问题

通过调用其工厂合同的create()方法,可以并将部署4个不同的合同。这样,我们就可以在已知地址的供应链上部署正式的工厂合同,并且我们可以确保以这种方式创建的所有合同都不会被篡改。每个工厂都保存通过调用其create()函数创建的所有实例的地址。很容易检查地址为A的合同是否由官方工厂创建

工厂合同列表:

  • AssetFactory.sol
  • IssuerFactory.sol
  • CfManagerSoftcapFactory.sol
  • PayoutManagerFactory.sol

Known issues

  • PayoutManager must take into account big token holders when distributing revenue based on some given snapshotID. For example, if token owner has sold 80% of the supply, he is still owner of the remaining 20%. But he doesn’t want to payout revenue to himself, he only wants to distribute rewards to the investors. One possible solution is to initialize the PayoutManager contract instance with the array of big addresses, and these are then taken into account when calculating the share in release(payoutID) function. This solution will be implemented if no better option is found.

transferable asset release candidate

部分转自网络,侵权联系删除区块链源码网

www.interchains.cc

https://www.interchains.cc/24088.html

区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » Tokenizer Contracts Prototype – 标记器契约原型区块链毕设代写

提供最优质的资源集合

立即查看 了解详情