eshon / conference

A simple Ethereum smart contract + DApp example
175 stars 106 forks source link

truffle init doesn't create config/app.json #3

Open Canalytic opened 8 years ago

Canalytic commented 8 years ago

truffle I am trying to follow the tutorial you posted on Medium. You linked this repo.

The third-step for deploying a smart contract is add the contract name to "contracts" in config/app.json

But I am using Truffle version 2.0.1 and truffle init does not create a 'config' directory in my project directory.

miglaros commented 8 years ago

Truffle 2.0 uses a different folder structure. The config directory has been replaced with a migrations directory. To get this project to deploy: 1) mkdir conference 2) cd conference 3) Run truffle init 4) cd contracts. If you do an ls, you will notice three Solidity files (ConvertLib.sol, MetaCoin.sol and Migrations.sol) I deleted ConvertLib.sol and MetaCoin.sol. You need Migrations.sol. Do not edit this contract. Create a new file and dopy the conference.sol contract from this repository into this file and save as Conference.sol. 5) cd ../migrations and do an ls. You should see two files (1_initial_migration.js and 2_deploy_contracts.js) These are crucial to deploying the truffle dapp. They need to be numbered in sequence. The 1_initial_migrations file deploys the Migrations contract and the 2_deploy_contracts deploys all your other contracts. 2_deploy_contracts needs to be edited so that it knows about your Conference contract. Edit this file - here's how mine looks: module.exports = function(deployer) { deployer.deploy(Conference); }; 6) truffle compile 7) truffle migrate 8) truffle build and everything should deploy without errors.

Where I am current stuck is when I run truffle test, I get Contract: Conference 1) Initial conference settings should match

No events were emitted 2) Should update quota No events were emitted 3) Should let you buy a ticket No events were emitted 4) Should issue a refund by owner only No events were emitted

0 passing (1s) 4 failing

1) Contract: Conference Initial conference settings should match: Error: Invalid address passed to Conference.at(): undefined at Function.Contract.at (/tmp/test-11675-13276-1a2cod1.r1ucakmx6r/Conference.sol.js:275:13) at Context. (test/conference.js:7:24)

2) Contract: Conference Should update quota: Error: Invalid address passed to Conference.at(): undefined at Function.Contract.at (/tmp/test-11675-13276-1a2cod1.r1ucakmx6r/Conference.sol.js:275:13) at Context. (test/conference.js:25:24)

3) Contract: Conference Should let you buy a ticket: Error: Invalid address passed to Conference.at(): undefined at Function.Contract.at (/tmp/test-11675-13276-1a2cod1.r1ucakmx6r/Conference.sol.js:275:13) at Context. (test/conference.js:42:24)

4) Contract: Conference Should issue a refund by owner only: Error: Invalid address passed to Conference.at(): undefined at Function.Contract.at (/tmp/test-11675-13276-1a2cod1.r1ucakmx6r/Conference.sol.js:275:13) at Context. (test/conference.js:68:24)

manindra23 commented 7 years ago

I did exactly as said in the above comments and it worked fine till step - 6(truffle compile) but when i run truffle migrate, I get the error:

test@test-ubuntu:~/Blockchain/Ethereum/conference$ truffle migrate
Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Server error
    at Object.module.exports.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/errors.js:35:16)
    at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/node_modules/web3/lib/web3/requestmanager.js:86:36
    at [object Object].request.onreadystatechange (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:114:13)
    at [object Object].dispatchEvent (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at nextTickCallbackWith2Args (node.js:441:9)
    at process._tickDomainCallback (node.js:396:17)

testrpc is up and running, and I see following two lines when I run truffle migrate:

127.0.0.1 - - [2016-10-21 09:38:17] "POST / HTTP/1.1" 200 718 0.001741
127.0.0.1 - - [2016-10-21 09:38:17] "POST / HTTP/1.1" 200 493 0.042596

Am I missing anything in the configuration? Source Code is at https://github.com/manindra23/conference-contract/tree/develop

teogenesmoura commented 7 years ago

@miglaros as for the first test, I think this reference might be useful: https://github.com/ConsenSys/truffle/issues/276