I have two contracts. One inherits a function that gets the value to be paid by the second one.

If I remove the 'is Reference' and replace the values from the external function, the code pays, without problems.

Am I doing something wrong here?

contract Reference {
    function getAmount(string) public returns(uint);

contract Payment is Reference{
    uint Value;
    address sender=msg.sender;// for the suicide

    function Payment (Reference _address, address _receiver, string _NR) payable {

        Value = _address.getAmount(_NR);

        if(!_receiver.send(Value)) {//pay

    //receive remainder of the money allocated to the contract
    function kill(){ 
        if (msg.sender == sender)

Thanks for any feedback!

Addition: If I define the values (amount to pay, recipient address) in the payment contract manually it doesn't get mined - this is as long as it still inherits from the other contract...

The extrnal function works fine...


The issue is that when Payment inherits from Reference ("is Reference") this implies it needs to implement any unimplemented functions in Reference (i.e. "getAmount") which you don't do - hence the contract won't be created.

Looking at your code, I can't really see why you'd want Payment to inherit from Reference. You don't rely on having a getAmount in Payment (i.e. this.getAmount) as you use the passed in Reference object for this function. Looks to me like you're confusing delegation (i.e. you delegate the getAmount function to the Reference object passed to the Payment constructor) with inheritance (where Payment itself would be a Reference and have an internal getAmount function).

So in summary, this works for me if: 1) I deploy a Reference contract (with the getAmount function implemented). 2) Deploy the contract in your question, but with "is Reference" removed (but with its constructor still calling the external contract reference created in 1). I pass the address of the contract created in 1) as the first argument.

One other thing to watch out for is that you have sufficient gas (presumably, although I'm not sure) calling out to an external contract will consume more gas than computing it internally.

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.