1

I am a newbie in Both Solidity and Programming. I want to deploy a contract in MIST test network with some ethar. whan i pressing the publish button following error is showing.

i have added the following payable function...

function payTestFunds() payable{
    //do nothing function
}

my intention is to give some ethar to my contract account so that it can process some further transaction by itself.

function payRentToCarRentalServiceProvider(address _providerAddress) returns (bool){

    bool payStatus = true;
    if(_providerAddress.send(rentCar[_providerAddress].rent))
    {
        rentCar[_providerAddress].rent = 0;
        return payStatus;
    }
    else{
        return !payStatus;
    }
}

kindly help me...Thanks in advance

enter image description here

1

I think if you want to send Ether during contract creation your function must be payable. If you are creating a new contract, making the function "payTestFunds()" payable is probably not enough, since the constructor is being called, not this method. Is your constructor also payable? For simplicity, start by deploying the contract without any initial Ether. Then send Ether once the contract is created.

Also, why are you declaring a variable that is only ever true and never changes? Just do

if (...) {
  return true; 
} else {
  return false;
}
| improve this answer | |
  • Agree with Max. To send ETH to the constructor, the constructor would have to be payable. Send nothing while you deploy the contract and then send a transaction to new payTestFunds() function after the contract is deployed. It's a 2-step. – Rob Hitchens Feb 9 '17 at 14:33
  • how can i make my constractor payable???i have tried tosome rther send after deploying but not worked :-( – TAMIM HAIDER Feb 9 '17 at 14:36
  • it works properly i have made my contractor also payable, simple write the payable keyword after the constractor name. Thanks a lot for your help – TAMIM HAIDER Feb 9 '17 at 14:53

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.