I developed my smart contract using tesrpc. Now I want to deploy them on the testnet. But I am not able to deploy them either with EtherWallet (I have the error "No data is deployed in the contract address", even if I maxed the fees) or with a JS script using the web3 api where i set Gas to 4700000. But i have no smart contract address back.

My smart contract code is:

pragma solidity ^ 0.4.2;

contract Color {

address public contracts;
string public color;

function Color(address _c, string _color) {
    contracts = _c;
    color = _color;

function getContracts() constant returns(address contractAddress) {
    return contracts;

function getColor() constant returns(string color) {
    return color;

function setlastDirAddress(address c) {
        contracts = c;

function setColor(string clr) {
        color= clr;



EDIT: Here is my JS script:

    var Web3 = require('web3');
var solc = require('solc');
const fs = require('fs');

var colorContract = {
    abi: null,
    address: null

//connect to testRPC / Geth locally
if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

// Checking Ethereum connection status
if (!web3.isConnected()) {
    console.error("Ethereum - no conection to RPC server");
} else {
    console.log("Ethereum - connected to RPC server");

//Setting up the account 
web3.eth.defaultAccount = web3.eth.accounts[0];
var account = web3.eth.accounts[0];

function compileAndDeployColorContract() {

    var contractAddress = process.argv[2];
    var color = process.argv[3];

    let source = fs.readFileSync('./color.sol', 'utf8');
    let compiledContract = solc.compile(source, 1);
    let abi = compiledContract.contracts['Color'].interface;
    fs.writeFile('./colorABI.js', abi, (err) => {
  if (err) throw err;
  console.log('colorABI.js saved!');
    let bytecode = compiledContract.contracts['Color'].bytecode;
    let gasEstimate = web3.eth.estimateGas({
        data: bytecode
    //run out of gas when using this
    let colorContract = web3.eth.contract(JSON.parse(abi));

    //Contract Object parameters
    var deployContractObject = {
        from: account,
        data: bytecode,
        gas: '4700000'

    var colorSC = colorContract.new(contractAddress, color, deployContractObject, function(err, colorSC) {
        if (!err) {
            // NOTE: The callback will fire twice!
            // Once the contract has the transactionHash property set and once its deployed on an address.

            // e.g. check tx hash on the first call (transaction send)
            if (!colorSC.address) {
                console.log('ColorTransaction Hash: ' + colorSC.transactionHash) // The hash of the transaction, which deploys the contract

                // check address on the second call (contract deployed)
            } else {
                console.log('ColorContract Mined! address: ' + colorSC.address) // the contract address


            // Note that the returned "myContractReturned" === "myContract",
            // so the returned "myContractReturned" object will also get the address set.
        else { console.log(err);}


I already had a look here, here and here.

Thanks for your answers,

  • Name of constructor in you contract should be same as the name of contract. Check it . Probably you have named the constructor 'User'
    – Aniket
    Apr 28 '17 at 7:31
  • Oh yeah. But I tried it again, but still the same error. Apr 28 '17 at 7:33
  • Exactly when you are getting that error, during deployment or while calling any function of contract?
    – Aniket
    Apr 28 '17 at 7:36
  • During the deployment Apr 28 '17 at 8:15
  • Can you paste the complete error msg? Does you action generate any transaction hash?console.log("Ethereum - connected to RPC server"); this line is being executed?
    – Aniket
    Apr 28 '17 at 10:31

This is a late reply, but i am leaving this for any future visitors Your solidity code seems to work fine, except that the getColor() function would not retrieve the correct value as a result of your returns statement; try: returns(string)
Try making use of the browser-solidity (Remix) tool: browser-solidity(Remix) upon loading the contract code, it compiles and also provides a working web3 deployment code.

Hope this helps

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.