How would one attempt to make a contract as the one drawn under:

enter image description here

To elaborate, an ICO happens. The conditions of the ICO are that there are x amount of ICO tokens. x minus y amount is sent to a list of wallet addresses, hardcoded into the contract. The remaining tokens are up for sale at a fixed token : ETH rate. The ETH deposited to the contract is then fowarded to a multisig address.

How would I go about attempting to code such a contract? Are there any resources or git repositories that are of similar logic?

  • 1
    Hi Alex, I am sorry that two people down voted your question without any comment or explanation. I raised this issue with the Meta team: ethereum.meta.stackexchange.com/questions/467/… – Tesa Jun 9 '17 at 14:02
  • Meanwhile, I up voted your question by +1 till someone can explain what the problem might be and you are actually given a chance to course correct. In the meantime, it might help to check out the section about what / how to ask: ethereum.stackexchange.com/help/on-topic and ethereum.stackexchange.com/help/dont-ask – Tesa Jun 9 '17 at 14:03
  • 1
    Well I down-voted because "This question does not show any research effort" and he is basically asking us to make the research – Crema Jun 9 '17 at 14:32
  • @Crema - Thank you for the clarification. Alex, if you don't want your question to get further down voted (or closed), you could edit it to show what you have already tried to do, and what you specifically need help troubleshooting. Here is an excerpt from "How do I ask a good question?": "Have you thoroughly searched for an answer before asking your question? Sharing your research helps everyone. Tell us what you found and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself" ethereum.stackexchange.com/help/how-to-ask – Tesa Jun 9 '17 at 15:48

Check out this sample ERC20-compliant fixed supply token example:

It pretty much builds in all of the logic for a basic token, with the ability to transfer tokens, approve withdraws, etc. You should be able to modify it pretty easily with a few extra functions/conditions to adapt it to your needs.

For giving tokens to the hardcoded list, you can just increment the token balances for addresses in the hardcoded list of wallet addresses.

For withdrawals just require that when people call a function to buy tokens, it converts ethereum to that token via a fixed rate, decrements the liquid supply, and sets their token balance accordingly. Then all ether will be stored in the contract, so you can make a basic withdrawal function that has an onlyOwner modifier, such that only the owner can withdrawal the funds. For multisig, you can expand this modifer by requiring consensus among a few users in order to withdrawal from the contract.

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.