IPFS四币循环系统开发|四币连发技术

IPFS四币循环系统开发、四币连发技术方案

1、四币循环:总发行量3000万枚,其中A币900万,B币800万,C币700万,D币600万。前三款币的51%由市场挖矿,49%由项目方挖出并用于市场(20%用于推荐奖励及市值管理,29%用于分红奖励)。
2、一机多挖
3、自带销毁

也许你经常看到ERC20和代币一同出现,ERC20是以太坊定义的一个代币标准。要求我们在实现代币的时候必须要遵守的协议,如指定代币名称、总量、实现代币交易函数等,只有支持了协议才能被以太坊钱包支持。搭建punk_2558,其接口如下:

contractERC20Interface{stringpublicconstantname="TokenName";stringpublicconstantsymbol="SYM";uint8publicconstantdecimals=18;//18isthemostcommonnumberofdecimalplacesfunctiontotalSupply()publicconstantreturns(uint);functionbalanceOf(addresstokenOwner)publicconstantreturns(uintbalance);functionallowance(addresstokenOwner,addressspender)publicconstantreturns(uintremaining);functiontransfer(addressto,uinttokens)publicreturns(boolsuccess);functionapprove(addressspender,uinttokens)publicreturns(boolsuccess);functiontransferFrom(addressfrom,addressto,uinttokens)publicreturns(boolsuccess);eventTransfer(addressindexedfrom,addressindexedto,uinttokens);eventApproval(addressindexedtokenOwner,addressindexedspender,uinttokens);}

简单说明一下:

name:代币名称symbol:代币符号decimals:代币小数点位数,代币的最小单位,18表示我们可以拥有.0000000000000000001单位个代币。totalSupply():发行代币总量。balanceOf():查看对应账号的代币余额。transfer():实现代币交易,用于给用户发送代币(从我们的账户里)。transferFrom():实现代币用户之间的交易。allowance():控制代币的交易,如可交易账号及资产。approve():允许用户可花费的代币数。

代币合约代码:pragmasolidity^0.4.16;interfacetokenRecipient{functionreceiveApproval(address_from,uint256_value,address_token,bytes_extraData)public;}contractTokenERC20{stringpublicname;stringpublicsymbol;uint8publicdecimals=18;//18是建议的默认值uint256publictotalSupply;mapping(address=>uint256)publicbalanceOf;//mapping(address=>mapping(address=>uint256))publicallowance;eventTransfer(addressindexedfrom,addressindexedto,uint256value);eventBurn(addressindexedfrom,uint256value);functionTokenERC20(uint256initialSupply,stringtokenName,stringtokenSymbol)public{totalSupply=initialSupply*10**uint256(decimals);balanceOf[msg.sender]=totalSupply;name=tokenName;symbol=tokenSymbol;}function_transfer(address_from,address_to,uint_value)internal{require(_to!=0x0);require(balanceOf[_from]>=_value);require(balanceOf[_to]+_value>balanceOf[_to]);uintpreviousBalances=balanceOf[_from]+balanceOf[_to];balanceOf[_from]-=_value;balanceOf[_to]+=_value;Transfer(_from,_to,_value);assert(balanceOf[_from]+balanceOf[_to]==previousBalances);}functiontransfer(address_to,uint256_value)public{_transfer(msg.sender,_to,_value);}functiontransferFrom(address_from,address_to,uint256_value)publicreturns(boolsuccess){require(_value<=allowance[_from][msg.sender]);//Checkallowanceallowance[_from][msg.sender]-=_value;_transfer(_from,_to,_value);returntrue;}functionapprove(address_spender,uint256_value)publicreturns(boolsuccess){allowance[msg.sender][_spender]=_value;returntrue;}functionapproveAndCall(address_spender,uint256_value,bytes_extraData)publicreturns(boolsuccess){tokenRecipientspender=tokenRecipient(_spender);if(approve(_spender,_value)){spender.receiveApproval(msg.sender,_value,this,_extraData);returntrue;}}functionburn(uint256_value)publicreturns(boolsuccess){require(balanceOf[msg.sender]>=_value);balanceOf[msg.sender]-=_value;totalSupply-=_value;Burn(msg.sender,_value);returntrue;}functionburnFrom(address_from,uint256_value)publicreturns(boolsuccess){require(balanceOf[_from]>=_value);require(_value<=allowance[_from][msg.sender]);balanceOf[_from]-=_value;allowance[_from][msg.sender]-=_value;totalSupply-=_value;Burn(_from,_value);returntrue;}}

在开发测试智能合约时,MetaMask和RemixSolidityIDE是两个非常好用的工具,用来完成部署。

你可能感兴趣的:(区块链)