Meteor DApp Cosmo - A Realtime Solidity Development Environment

SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
edited April 2015 in Smart Contracts and Dapps
I wanted to make a DApp that would allow me to thoroughly vet and test solidity contracts fast. So I used Christian's realtime solidity compiler as a base, and build a dev environment DApp on top of it. The result, Cosmo, a light-weight realtime solidity development environment that allows you to write, deploy, vet, test and operate solidity contracts in your browser.

Once I integrate connection toggling, I'll release a deployed POC on meteor.com. For now, you will have to run it manually with Meteor.

A special thanks to Christian and the CPP-Dev's for putting together the in browser compiler. Also, keep an eye out for Mix, the official development environment for Solidity that is still under development.

You can checkout the project here:
https://github.com/SilentCicero/meteor-dapp-cosmo

All the best, SC.

«1

Comments

  • awrelllawrelll BucurestiMember Posts: 65 ✭✭
    Silent Cicero strikes again... awesome work man !
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
  • rfikkirfikki Palm Beach, FloridaMember Posts: 26
    Yes, very nice.
  • VraminVramin Member Posts: 10
    This looks great, will give it a try this weekend.
  • oomooomo Member Posts: 31
    @SilentCicero You are totally awesome! I guess I posted my request at the right place. I have downloaded it and I will try it out and and have my engineers look at it also. Thank You!
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    @oomo thanks, keep an eye out for the latest built coming up, I'll be upgrading Cosmo to the latest SOL compiler. Cheers!
  • oomooomo Member Posts: 31
    @SilentCicero Looks like you are using an external Sol compiler. The JS implementation is not yet functional.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    Yes, its external of sorts. A new edition of the SOL compiler was released by Christian as I was building this, so I'll upgrade to that one shortly.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    Just upgraded to the latest CPP sol compiler js. FYI.
  • VraminVramin Member Posts: 10
    I like where you're going with this, it's helping me to grok how Ethereum all fits together. I've noticed that, per your update, Chrome really only works with the debug console open, Safari doesn't seem to work at all, and Opera works right out of the box for the client. I haven't puzzled out the right ways to interact with your ballot contract, but I have gotten it to perform a few operations. Many thanks for piecing this together, it is very educational.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    edited April 2015
    @Vramin thank you, yes that was the intention, it's to get you connected and into the head space of DApp construction while also making it easier to design durable Ethereum contracts. Please excuse the browser problems, it's hard to fit a CPP-compiler converted to JS into a MeteorJS app as MeteorJS does not like the CPP converted bytecode operands as the conversion is, naturally, not up to standard with common JS coding styles/practises that MeteorJS is use too, primarily b/c it does a lot of work with very intensive bytecode which is not very common in JS applications now a days. However, most browsers still render it fine. I'm working on getting good cross-browser performance/reliability. But it's a work in progress. Also, geth will have an in-house solidity compiler soon as of #774, so If I cant get good cross-browser reliability from the SOL.js compiler now, I will implement a cross-compiler option to switch between geth and the in-browser compiler. However, right now it's just the in-browser compiler. As for Chrome, try opening the console, switching to debug, refreshing (with the console open), then closing the console. Thats how I work with Cosmo in Chrome (it's a bit of hack but I know it works). I dont know about Safari, but Firefox is another option, it just takes a second to boot (make sure you have the latest Cosmo repo, I updated w/ some critical updates last night). Cheers!
  • StephanTualStephanTual London, EnglandMember, Moderator Posts: 1,282 mod
    Absolutely brilliant! Thank you for sharing this @SilentCicero
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    Just added connection toggling, so here is a hosted version on meteor.com (also the http provider is changeable):

    http://meteor-dapp-cosmo.meteor.com/
  • oomooomo Member Posts: 31
    @SilentCicero I am looking at your hosted version. How do I change the connection? or its not changeable. Can I change the http provider to be somewhere on cloud?
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    Hey oomo, it would be recommended to set it to your local geth http provider, generally http://localhost:8545

    In regards to the cloud, I don't have any cloud setup for this, its localhost only at the moment (i.e. this will connect with your local geth node).

    You need to make sure your corsdomain geth param is set too: http://meteor-dapp-cosmo.meteor.com

    I'll be putting recommended geth settings up soon (on the actual utility).
  • oomooomo Member Posts: 31
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    Just updated Cosmo with better load staging for the soljson.js compiler and @oomo added a reactive recommended geth settings tab (http://meteor-dapp-cosmo.meteor.com).
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    More updates - async for calls, transactions; auto compile is turned off on boot for better performance; clean JSON option for abi. http://meteor-dapp-cosmo.meteor.com/
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    The Cosmo website is up: http://cosmo.to/ - follow Cosmo on twitter @CosmoUp
  • VraminVramin Member Posts: 10
    Nice work, @SilentCicero.

    I'm still a little bit green at all of this, I suppose. One important safety tip I've learned is that you do have to be mining for this to work. I've been able to deploy the contract and see address set as the chairperson, and the number of proposals properly set to 5. I've granted the right to vote to a couple of additional addresses and I've attempted to cast votes from those addresses. I get this type of output from voting:

    Tx -> Ballot @ 0x127.. vote(1)

    However, I can't seem to get any results out of the proposal, and people who did vote show up with their voted value as false:

    Call -> Ballot @ 0x127.. voteCounts():
    0
    Call -> Ballot @ 0x127.. voteCounts(1):
    0
    Call -> Ballot @ 0x127.. winningProposal():
    0
    Tx -> Ballot @ 0x127.. voted(0xd38a9416d74261dc4df66f87829263b07fd1b856)
    Call -> Ballot @ 0x127.. voted(0xd38a9416d74261dc4df66f87829263b07fd1b856):
    false

    I'm probably just misunderstanding how the contract is supposed to work. I have three accounts, all have voted for proposal 1.

    Looking forward to understanding better.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    edited May 2015
    @Vramin so there are a few things that could be going wrong here.

    1) While you have three accounts created, you may not have unlocked them when you want to vote as them.

    - Did you unlock the account you wanted to use when you started your geth node, or is it still on "--unlock=primary"
    - If you left it on unlock primary, you will need to switch that to the current account you would like to use to vote with on the ballot contract.
    - So in this case, you would deploy and vote with one. Stop the geth node, then set the --unlock=YOUR_NEXT_VOTING_ACCOUNT_ADDR, then start up the geth node with these new cmd line params, then re-connect with geth in Cosmo, then vote again as the new unlocked account.
    - Although in doing this, you would loose the Cosmo session on restarting/or reconnecting Cosmo (potentially), so this may not work until I get address injection working (that's for later... I'll make a pull request and keep you posted).

    2) Gas, you don't have the amount of gas required to interact with or make the contract (a low balance on the current account you have unlocked)

    - Do you have enough gas to send transactions to and deploy the contract, if you have unlocked a new account, there is a good chance that newly unlocked account has low to no gas, as you need to switch the mining params to mine to that new address in the geth cmd line in order to build up gas on that account.
    - Although, I'm only addressing this issues, if it is the case you cant get anything working with this contract.

    This default Ballot contract is generally to show basic functionality, actually switching accounts and voting as another account (i.e. person) may prove either difficult or impossible with the present setup (but with more functionality it will be possible soon).

    If you have not been able to get anything working (e.g. transact vote (proposal id) then call voted (your addr)), then it's most likely a corsdomain, gas, unlock or mining issue.

    One thing that could help is opening up the console (CNTL+SHIFT+I) while using Cosmo and read/look for errors and whats happens when you connect, deploy and vet the contract. You can post the console output here.

    Note, there is two boot errors in the console already, one regarding a theme and another regarding uncaught exception, ignore these. Look what happens after these errors, when you connect to geth and onward.

    Cheers, lets get you setup
  • oomooomo Member Posts: 31
    @SilentCicero So what @Vramin is asking is specific to the Ballot contract example that you have. Though, what it appears to me is similar to the problem that we are also trying to solve, where I would like to transact on the contract in behalf of someone else (or some other account). Can one do this? Your suggestion of starting geth with different account everytime I want to transact as someone else doesn't seem practical or efficient. I know this is not Cosmo specific question, but it is an overall Ethereum functionality.

    BTW, now that you are hosting the Cosmo on your own site, does that mean that you are no longer contributing this to GitHub? My team is using your fine tool for development of the contracts and learning Ethereum APIs while looking at the cosmo code. It has been very helpful tool for us. Thanks
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    edited May 2015
    @oomo so Ethereum will streamline this unlocking process as they continue to work on the clients going forward. Right now, you unlock the accounts on the geth command line (at least that is what I'm aware of presently as the most secure option). However, as Web3.js comes along I can add more account functionality. So, yes, this functionality should be coming along real soon to do account toggling etc. But presently, acting as other addresses with Cosmo on Ethereum is a little on the tough side.

    In regard to your other question, the plan is to get all critical aspects of Cosmo on Github and for it to be open-source, i.e. all the stuff you see now, plus event handling, natspec and a few other features.

    All core aspects of the Web3.JS object will be available in Cosmo's core client on Github, totally open-source and free. Note, I just haven't updated the Github repo with the latest build, which is why you haven't seen the latest updates. I will do that today.

    Going forward, Cosmo's hosted service will feature some premium account services for little extras that are not core Web3.js functionality. But these services will be targeted and narrow with the premium service largely a supportive measure to continue the development of Cosmo. But expect Cosmo, at least all core aspects, to be totally open-source, free, hosted and available on Github.
  • VraminVramin Member Posts: 10
    Thanks, @SilentCicero. I guess I need to circle back and understand geth a bit better. I appreciate the detailed answer. I didn't realize I had to start geth in a certain way, etc. One step closer. ;)
  • rfikkirfikki Palm Beach, FloridaMember Posts: 26
    @SilentCicero tried cosmo but it is crashing:

    C:\Users\Rocky\Documents\GitHub> cd meteor-dapp-cosmo
    C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo [master]> cd app
    C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app [master]> ls


    Directory: C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app


    Mode LastWriteTime Length Name
    ---- ------------- ------ ----
    d---- 5/29/2015 11:06 AM .meteor
    d---- 5/29/2015 11:06 AM client
    d---- 5/29/2015 11:06 AM i18n
    d---- 5/29/2015 11:06 AM public
    -a--- 5/29/2015 11:06 AM 117 project-tap.i18n
    -a--- 5/29/2015 11:06 AM 80 settings.example.json


    C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app [master]> meteor
    [[[[[ C:\Users\Rocky\Documents\GitHub\meteor-dapp-cosmo\app ]]]]]

    => Started proxy.
    => Started MongoDB.
    => Errors prevented startup:

    While checking for mizzao:[email protected]:
    error: No compatible binary build found for this package. Contact the package author and ask them to publish it
    for your platform.

    => Your application has errors. Waiting for file change.

  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    @rfikki so the mizzao:sharejs package is a very old and badly written Meteor package. It handles the visual code environment/editor Ace and is not an essential aspect of Cosmo, it's just what we are using right now. We are looking to switch this out for a more developed and mature coding editor. I'll take a look at the build today, but I think for now using the in-browser build is probably your best bet.

  • rfikkirfikki Palm Beach, FloridaMember Posts: 26
    I actually was attempting to learn from your code and environment setup. That is why I was compiling/running your app from the instructions in your repo. I am not that familiar with the meteor setup and wanted to see how it all worked together in a functioning ethereum dapp.
    Thanks for your response. Hopefully, it will be functioning soon. Did you build this in Visual Studio? If so, what version?
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    @rfikki thats awesome, glad to see someone is building it out and learning from it! Well the build works for me, with the single "meteor" command in the app folder.

    So my questions are: what version of Meteor are you using (cmd: "meteor --version"), and is this a fresh git clone of the Cosmo repository?

    Re: Visual Studio, no, it's all done in web friendly, lightweight languages (i.e. HTML, LESS -> CSS and Meteor's built in real-time visual framework).
  • rfikkirfikki Palm Beach, FloridaMember Posts: 26
    edited May 2015
    @SilentCicero version of meteor is 1.1.0.2
    I will try to do a new git clone and make sure I have the latest repo of Cosmo. Let me know whether my version of Meteor should work?
  • rfikkirfikki Palm Beach, FloridaMember Posts: 26
    I submitted an issue with the package author here: https://github.com/mizzao/meteor-sharejs/issues/49
Sign In or Register to comment.