Self-destributing token contract template
Self-destributing token contract template
Self-destributing token contract template Hello, Are there any complete templates or resources for making a token which distributes itself when funds are sent to the contract I. e. user sends 0.01 ETH to contract, which in turn sends X tokens back to user. I would prefer blockchain based solutions but if none are available then maybe a server based solution. Vesa
This is a very common feature in tokens. Heres an incomplete example you can play around with: pragma solidity 0.4.23; import https:github.comOpenZeppelinzeppelin-soliditycontractstokenERC20StandardToken.sol; contract TestToken is StandardToken uint256 public tokensPerEther 1000; constructor public totalSupply_ 10000; balancesthis totalSupply_; function payable external this.transfermsg.sender, msg.value tokensPerEther;
Use this one, its a very well tested implementation of token distribution contracts, which is used as a base for many projects in the ethereum space. https:github.comOpenZeppelinopenzeppelin-solidity specifically, look under contractscrowdsale in the code.
Комментарии
Отправить комментарий