0

I have created previous contracts where the token is created by the crowdsale and then the constructor allocates an amount of those to be transferred to other addresses and the remainder are for sale.

But how do I implement logic that allows me to set an already created token as the token to be used in the crowdsale and then send those tokens to the contract and have them for sale?

Thanks for any help.

1
  • We don't have enough information to help you. Please share the source code of the existing contracts.
    – Jesbus
    Jul 5 '18 at 9:18
1

It depends on who currently owns the tokens which you want to sell in the crowdsale. You need to have a way to transfer those tokens somewhere. If you have this access, you can just write a crowdsale contract which references the token contract and calls its methods to send the tokens elsewhere with some logic (crowdsale).

Here's an example crowdsale: https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/SampleCrowdsale.sol

0

I see this is kind of old, but it's not marked as answered.

I was looking for what I think you are/were after. Basically you wish to sell tokens from an existing contract as crowdsale, if I get you correct.

https://github.com/Creepybits/Allocated-crowdsale

Edit for clarification

I used OpenZeppelins crowdsale contract (v2.5.0) and flattened it with Remix flattener-plugin.

Note: the remix flattener doesn't always put the different parts of the contract in the right order when flattening so you might have to manually move them around until they are positioned correctly

Then you want to deploy your crowdsale contract at the contract address of the token you wish to sell.

It'll look like this.

Whether the tokens you wish to sell is in your wallet or is located in a contract you own, you can now transfer the tokens you wish to sell to the crowdsale contract.

When someone sends X ETH (or BNB is that's what you are using) they will recieve Y tokens and the ETH (or BNB) will be forwarded to the wallet address you specified when you deployed your crowdsale contract.

This is how I have done it with 2 different tokens, and it's working for me. I never managed to get the crowdsale contract verified though, but it's working anyway.

1
  • 1
    Link only answers are not recommended. It will be nice if you can include the main changes required in the answer and only use the link to fill the details.
    – Ismael
    Jun 24 at 19:18
-1

I think what you are looking for is an Escrow smart contract implementation.

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.