0

I need to call a function from another contract (the function take a parameter and need 1 Ether to execute) like this:

    pragma solidity ^0.4.4;
    contract ContractONE {    
       uint public i;
       function register(uint _i) payable{
          if(msg.value > 1 ether){
             i = _i;
          } else {revert();}
        }
       ...
    }

............................................

pragma solidity ^0.4.4;
  import "./ContractONE.sol";
  Contract contractTwo {

     address addofContract1;
     uint i ;
     ....
     function changeNum(uint _i) payable{
         i = _i;
         ContractONE c = ContractONE(addofContract1);
         //// problem here:
         c.register(_i); //will revert, cause it does not send ether!!
        ////
      }
    }

the second Contract has already some Ether in it.

is there a method to do that? maybe like c.register(_i).transfer(amount)! or a trick with addofContract1.call(.....,.....)

2

i found the answer

c.register.value(msg.value)(_i);
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.