4

I was just recently going through programtheblockchain.com posts which are really helpful in terms of learning.

I am currently struggling to deploy Token Market Contract (https://programtheblockchain.com/posts/2018/02/27/writing-a-token-market-contract/) which uses import function to import part of a code from separate file. Seems like remix not finding tokenmarket contract to deploy (parserError: Expected token Semicolon got 'Interface' interface IERC20Token { ) Any change anyone knows what is the issue here, maybe there is an issue in the code itself? Although I bet it is me not knowing how to deploy multiple files.

Thanks,

dodocod
  • 41
  • 2

1 Answers1

0

Looks like they have a couple errors in their code. First off, you need to have a semicolon after import statements:

import "./ierc20token.sol";

Also, they are attempting to import an interface (IERC20Token) and declare one with the same name.

EDIT - The tutorial has been updated. Try the latest version and see if that resolves your issue.

Adam Kipnis
  • 670
  • 1
  • 5
  • 12
  • 1
    Sorry about the bad edit there. We introduced "ierc20token.sol" later and apparently botched editing old posts. :-( I've just fixed up the code in that post, and we'll take a look at the rest of that diff and see if we can spot any other mistakes. Apologies for the trouble and wasted time! – user19510 Mar 31 '18 at 08:37
  • 1
    I found two more errors in that diff, hopefully all is fixed now. Thanks for spotting the issue! – user19510 Mar 31 '18 at 08:43
  • Didn’t know it was your tutorial, @smarx. Definitely trustworthy ;) – Adam Kipnis Mar 31 '18 at 15:45
  • @smarx, great stuff, thanks for getting back and correcting it ;) – dodocod Apr 01 '18 at 21:07
  • Hello @smarx, do you mind me asking about the sequence of operating marketplace. So far I approved the address and amount, and successfully listed tokens sitting on the approved address. However not able to buy those or do anything else. Also in your opinion, where is the best place to test it: Mist, Remix, MEW, other? Somehow I am not able to get it working in MEW. After contract is loaded not able to do anything else - read, write options are not responding. Remix looks better. Lastly, maybe you remember the contract id you created when testing? I would refer to it to understand better. Thx! – dodocod Apr 02 '18 at 21:52
  • 1
    I usually stick to Remix for trying this stuff out so I can deploy to the JavaScript VM, which seems like the lightest weight way to try things out. I don't think my partner (who wrote the post) or I ever deployed it to a live network. We deployed it to the JavaScript VM in Remix and to a local network to run tests on it. – user19510 Apr 03 '18 at 03:27
  • 1
    As to the sequence, you should deploy the token contract, then deploy the token market contract, then (in either order) approve tokens for the contract to spend and call list to list them for sale. Finally, call buy, passing the ID you got back from list and passing the amount to buy and attaching the right amount of ether. It's a bit tricky to get all those things done. Feel free to ask a new question (and flag me in the comments with @smarx!) if you're still stuck on a specific step. – user19510 Apr 03 '18 at 03:29
  • Thanks @smarx. When you mentioned "deploy the token contract, then deploy the token market contract", you meant to say that "IERC20Token" (all the functions specified in ierc20token.sol) should be deployed separately? Is that needed, as tokenmarket.sol imports ierc20token.sol? Also, deploying IERC20Token using ierc20token.sol doesn't seem to be working as it points out to functions (This contract does not implement all functions and thus cannot be created) and rejects the to deploy. So assuming we don't need to deploy is separately ? Please correct me if I am wrong. – dodocod Apr 03 '18 at 21:59
  • In terms of testing I was referring to address on test net. I am using Injected web3 as it looks to be close to live deployment - creating all the contract reference addresses etc. - I thought (based on one of your trainings where you used it) it is most common practice when working on the test net. – dodocod Apr 03 '18 at 21:59
  • 1
    No, you need to deploy an actual ERC20 token, with a full implementation. We have one such implementation on the blog: https://programtheblockchain.com/posts/2018/01/30/writing-an-erc20-token-contract/. – user19510 Apr 03 '18 at 22:33
  • 1
    We didn't deploy to a public test network (e.g. like Ropsten). – user19510 Apr 03 '18 at 22:34
  • @smarx sorry for stupid questions (sooo new to this..). So the point of this marketplace is to list tokens of the same contract? Like if we have ERC20 token “SET” created on a contract we can then distribute it to different addresses, people owning those addresses/tokens can list them on the marketplace for others to buy? Is that the purpose?

    I was under impression that it will allow to list any tokens. Eg if I have ABC on address A, and DEF on address B, I could list it with my price for someone to buy, even if I am not a creator of a token contract.

    – dodocod Apr 03 '18 at 23:10
  • 1
    Your impression was correct. This contract can be used to sell any token, and anyone who holds tokens (of any type) can list their tokens for sale. – user19510 Apr 03 '18 at 23:11
  • @smarx, so it is not necessary to deploy actual ERC20 token if for instance I use Interface web3 and have tokens in another account? I can use that account to list tokens sitting on it, right? – dodocod Apr 04 '18 at 11:38
  • Just a general suggestion to consider deploying to test net, doing tests there and then adding contract address to your blog so that it would be easier for your audience to understand. When reading blog sounds super clear, but when actually trying stuff, a lot of questions pops up. Nevertheless it is great that you are educating people on this subject. – dodocod Apr 04 '18 at 12:42
  • 1
    @dodocod Correct. You just need an ERC20 token. If you already have one you want to use, you don't need to deploy a new one. I'm not sure I follow why seeing a deployed instance on a test network would help. – user19510 Apr 04 '18 at 16:01
  • @smarx, well, I find the most confusing part to understanding how may parties (different accounts) are participating here and what action should be processed/signed with which account. Thank you, I will create a new final question listing all the steps I am doing and will ask for your help on tinkering it out. Perhaps it will be useful for someone else as well. – dodocod Apr 04 '18 at 20:07
  • @smarx, just posted. Looking forward for your input. Appreciate your every response. https://ethereum.stackexchange.com/questions/44787/deploying-token-marketplace – dodocod Apr 04 '18 at 20:56