1

This might be a very general question, though I'd like if someone could clarify on how to within a crowdsale contract use an already deployed token contract with a fixed supply. I know how to create a mintable token internally from the crowdsale contract but I've never played around with an existing token though. Thank you

2

On your crowd sale contract, import the ERC20 interface and then code your smart contract to allow an ERC20 token to be set.

function setToken(address tokenAddress) {
        require(msg.sender == _ownerAddress);        
        _myToken = ERC20(tokenAddress);
    }

Now your crowd sale contract can call _myToken.balanceOf(this); to get the number of tokens it owns, and _mytoken.transfer(address, count); to distribute tokens according to whatever your desired crowdsale logic is.

So now all you need to do is transfer some or all of your minted tokens to the crowdsale contract address and you're ready to go.

0

If the token contract has an owner and a function to transfer ownership to another address, and a minting function which can only be called by the owner of the contract, then it is possible by setting the token owner to be the ICO contract.

  • Think you misunderstood me bro :-) – NowsyMe Oct 30 '17 at 1:36
0

Did you manage to make it work? In the green marked answer I read: "import the ERC20 interface"; does this mean to import the ABI interface or the Solidity code of the already deployed token contract?

0

TokenMarket ICO contains an out of the box token sale smart contract AllocatedCrowdsale.

You put tokens for sale using EIP-20 approve().

https://github.com/TokenMarketNet/ico/blob/master/crowdsales/allocated-token-sale-example.yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.