Basically I have this code where I'm trying to divide a specific amount of ether into two different function calls within the contract.

function singleTransaction(arg1) payable { require(msg.value == 1 ether); buy.value(msg.value / 2)(buy_arg); // diff function in contract subscribe.value(msg.value / 2)(subscribe_arg); // diff function in contract }

But I'm getting this error on migration: TypeError: Member "value" not found or not visible after argument-dependent lookup in function (uint256) - did you forget the "payable" modifier?

I found a different stack exchange article suggesting the format I've posted, so not sure where to go from here.

  • Truffle v5
  • Solidity 5.0
  • 1
    This syntax doesn't seem to make much sense. What are buy and subscribe? It looks from the error like maybe those are functions in the same contract. Internal functions can't be payable, so you can't use that syntax with them. Why not just pass the amount as a parameter? (foo(msg.value / 2, ...)) – user19510 Sep 27 '19 at 22:40

TL;DR call payable methods on a different contract

As Michael C says in the previous comment (probably meant to be an answer):

buy and subscribe look like you mean them to be different methods in the same contract. However, the value has already arrived to your contract through the payable singleTransaction method, so there's no way to split up the value now: all of the value will go into the current contract's balance if the tx succeeds.

You can call payable methods on a different contract, and then send half the value to each one, using the syntax that you used above, and following the advice in this other answer

The key line below specifies which contract you are expecting to call this payable method on


The full source file is:

import "./SafeMath.sol";

contract Constants {
    uint8 public constant BUY_ID = 1;
    uint8 public constant SUBSCRIBE_ID = 2;

contract BuyContract is Constants {

    uint256 public lastAmount;

    function buyMethod(uint8 _buyArg) payable public {
        require(_buyArg == BUY_ID);
        lastAmount = msg.value;


contract SubscribeContract is Constants {

    uint256 public lastAmount;

    function subscribeMethod(uint8 _subscribeArg) payable public {
        require(_subscribeArg == SUBSCRIBE_ID);
        lastAmount = msg.value;


contract MyContract is Constants {
    using SafeMath for uint256;

  function singleTransaction(
      address _buyAddress,
      address _subscribeAddress
  ) payable public {
      BuyContract buyContract = BuyContract(_buyAddress);
      SubscribeContract subContract = SubscribeContract(_subscribeAddress);
      uint256 halfValue = msg.value.div(2);


Here's the full example in this gist: https://gist.github.com/cryptogoth/9bb1caa9193adb73dc640ec8f979963e

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.