Skip to main content
added 249 characters in body
Source Link
jayD
  • 2.5k
  • 2
  • 15
  • 25

My advice would be to use the Browser Solidity:

Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy:

var _numProposals = /* var of type uint8 here */ ;
var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]);
var ballot = ballotContract.new(
   _numProposals,
   {
     from: web3.eth.accounts[0], 
     data: '60606040*deleted-for-lsibility-6', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

Don't forget that :

  • It's javascript ( so address is string )
  • You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

--

Another solution is Mix IDE :

Click on Deploy then click on Open Compilation Result and it will provide you with a JS file. Inside there are objects representing your contract. You would then need to call web3.eth.contract(Mycontract.abi)

My advice would be to use the Browser Solidity:

Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy:

var _numProposals = /* var of type uint8 here */ ;
var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]);
var ballot = ballotContract.new(
   _numProposals,
   {
     from: web3.eth.accounts[0], 
     data: '60606040*deleted-for-lsibility-6', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

Don't forget that :

  • It's javascript ( so address is string )
  • You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

My advice would be to use the Browser Solidity:

Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy:

var _numProposals = /* var of type uint8 here */ ;
var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]);
var ballot = ballotContract.new(
   _numProposals,
   {
     from: web3.eth.accounts[0], 
     data: '60606040*deleted-for-lsibility-6', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

Don't forget that :

  • It's javascript ( so address is string )
  • You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

--

Another solution is Mix IDE :

Click on Deploy then click on Open Compilation Result and it will provide you with a JS file. Inside there are objects representing your contract. You would then need to call web3.eth.contract(Mycontract.abi)

added 74 characters in body
Source Link
q9f
  • 33k
  • 47
  • 157
  • 399

My advice would be to user Browser solidityuse the :

http://chriseth.github.io/browser-solidity/Browser Solidity:

Just copy past youpaste your contract, and if it compilecompiles without errors you can just copy past the content of Web3 deploy  :

var _numProposals = /* var of type uint8 here */ ; var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]); var ballot = ballotContract.new( _numProposals, { from: web3.eth.accounts[0], data: '60606040*deleted-for-lsibility-6', gas: 3000000 }, function(e, contract){ console.log(e, contract); if (typeof contract.address != 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })

var _numProposals = /* var of type uint8 here */ ;
var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]);
var ballot = ballotContract.new(
   _numProposals,
   {
     from: web3.eth.accounts[0], 
     data: '60606040*deleted-for-lsibility-6', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

-It's javascript ( so address is string ) -You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

  • It's javascript ( so address is string )
  • You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

My advice would be to user Browser solidity :

http://chriseth.github.io/browser-solidity/

Just copy past you contract, and if it compile without errors you can just copy past the content of Web3 deploy  :

var _numProposals = /* var of type uint8 here */ ; var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]); var ballot = ballotContract.new( _numProposals, { from: web3.eth.accounts[0], data: '60606040*deleted-for-lsibility-6', gas: 3000000 }, function(e, contract){ console.log(e, contract); if (typeof contract.address != 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })

-It's javascript ( so address is string ) -You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.

My advice would be to use the Browser Solidity:

Just copy paste your contract, and if it compiles without errors you can just copy past the content of Web3 deploy:

var _numProposals = /* var of type uint8 here */ ;
var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]);
var ballot = ballotContract.new(
   _numProposals,
   {
     from: web3.eth.accounts[0], 
     data: '60606040*deleted-for-lsibility-6', 
     gas: 3000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })
  • It's javascript ( so address is string )
  • You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.
Source Link
jayD
  • 2.5k
  • 2
  • 15
  • 25

My advice would be to user Browser solidity :

http://chriseth.github.io/browser-solidity/

Just copy past you contract, and if it compile without errors you can just copy past the content of Web3 deploy :

var _numProposals = /* var of type uint8 here */ ; var ballotContract = web3.eth.contract([{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"winningProposal","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[{"name":"voter","type":"address"}],"name":"giveRightToVote","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposal","type":"uint8"}],"name":"vote","outputs":[],"type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"type":"constructor"}]); var ballot = ballotContract.new( _numProposals, { from: web3.eth.accounts[0], data: '60606040*deleted-for-lsibility-6', gas: 3000000 }, function(e, contract){ console.log(e, contract); if (typeof contract.address != 'undefined') { console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash); } })

Don't forget that :

-It's javascript ( so address is string ) -You need to fill your params var _numProposals = /* var of type uint8 here */ ; here.