4

I am trying to somehow end up with a solidity code (for an Ethereum token and a Crowdsale contract), that I can paste in the source code bar in Ethereum Wallet and deploy the Token and the Crowdsale ICO.

Most of the sample/example/finished codes online are for an older solidity version and don't function anymore. I am also not capable of changing them to make it work. Despite my low to zero coding experience, I have a feeling that most of the changes in solidity versions include fundamental improvements, which leads me to think older examples are not the thing I should look for.

I found https://github.com/OpenZeppelin/zeppelin-solidity where everything is up to date and has examples of most of the smart contracts that one may need.

Using various tutorials I extracted some of the files from Zeppelin and made some on my own (one for the coin and one for the crowdsale).

Most of the files in Zeppelin have other files linked in their code. For me to deploy a contract, I need one code without linked libraries.

I thought the word "compile" is what I am looking for and using Truffle managed to compile them, but I just got all the separate files, but in .json.

How can I make one single code, that could be used in apps like Ethereum Wallet to deploy a contract. Will it work if I just copy-paste everything together (should work, but I have a feeling that this is not the smart way).

1

This is by no means a complete guide, but in essence, to compile, migrate and work with contracts on your local computer you would need to:

1) Setup node.js on your computer. The process for doing this heavily depends on the computer you are using.- https://nodejs.org/en/

2) Install the Truffle framework and testrpc to make working with smart contracts easier.

 `$ npm install -g truffle` <- this installs the framework on your computer
 `$ npm install -g ethereumjs-testrpc` <- this installs the testrpc to allow connecting to the development network on your computer 

3) Create a directory, then in a command prompt or terminal window, initialize a truffle project inside of it.

`$ cd <directory_you_created>`
`$ truffle init` <- starts a new truffle project

4) Develop your smart contracts, then run the compile command.

`$ truffle compile`

5) In a separate command prompt or terminal window, run the following command to start a development network instance.

`$ testrpc --secure -u 0 -u 1` <- this will start the development network and unlock the first account that comes with testrpc automatically

6) Write the contract migration code, then migrate your smart contracts to the development network.

`$ truffle migrate`

7) Next you need to connect to the truffle console which allows you to interact with them through the testrpc instance.

`$ truffle console`

From there you can interact with your contracts using normal javascript commands. Again, please refer to the documentation.

Developing smart contracts is not for the faint of heart. If you have zero coding experience, I highly suggest hiring a competent web developer to help you. I have intentionally left out writing tests for your smart contracts for brevity, but I highly suggest doing so.

Full documentation: http://truffleframework.com/docs/getting_started/installation

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.