1

Here I am having an issue where the values are not appearing to function correctly in the Remix IDE browser.

I am trying to have a buyer where they can transfer funds to each other, and the seller can add a description and retrieve the description.

The issue I am finding is when I execute the at the address I can't appear to get the amount from the Buyers contract. The only thing that happens when I click on getAmount it executes but returns nothing.

Any help would be appreciated.

Below is the code I entered into Remix:

 pragma solidity ^0.4.17;

contract Buyer {
        //event LogDescription(address sender, uint amount);
        uint  amount;
        mapping (address => uint) balances;

    function send(address receiver, uint amount) {
        if (balances[msg.sender] < amount) return;
            //if (amount < 10 ether){
                balances[msg.sender] -= amount;
                balances[receiver] += amount;
                //LogDescription(receiver, amount);
            //}
    }

   function getAmount() returns(uint) {
        return(amount);
    }

}

    contract Seller{
        string description;

        Buyer bartscontract;

        function SetDescription(string _description) public {
            description = _description;
            //LogDescription(msg.sender, msg.value, description);
        }
        function getDescription() constant public returns(string) {
            return description;
        }




    }

Here are some screenshots for send and receive ether for further analysis. Below is for Sending 1 Ether to the address: enter image description here

Below is for trying to get or view ether sent to the specified address. enter image description here

2 Answers2

2

Your function getAmount do not modify the storage so you can mark as a view

function getAmount() public view returns (uint) {
    return(amount);
}

Remix will create a call when you use the function getAmount.

See this question: What is the difference between a transaction and a call? to understand the difference between a transaction and a call.

Ismael
  • 30,570
  • 21
  • 53
  • 96
1

The other question I have here is why no value is given and the console just responds back with a call to Buyer.getAmount()? Then no value is actually given back. Is this an error or glitch?