pragma solidity ^0.4.17;
                //  I want to write a code for  loyalty points when user pays 
                contract GiveRefreceId {

                     mapping(address => uint256) public referenceid;
                        address[] public clients;
                        uint256 idcounter;

                    struct  MlMMembership_Payment{
                        string CompanyName;
                        uint256 DistributorId;
                        uint256 RefrenceDistributorId;
                        uint256 Amount;

                    MlMMembership_Payment[] MlMember;

                        event createdId(address user, uint256 id);

                        function giveRefrenceId() public returns (uint256)  { 
                            idcounter += 1;
                            referenceid[msg.sender] = idcounter;
                            emit createdId(msg.sender,idcounter);
                            // return createdId[1]
                            return idcounter;

    function MLMloyalityPoints(string _Compney_name,uint256 _refreeid) public payable {
        uint256 temprefreeid  =  _refreeid-1;
        var  tempaddress = clients[temprefreeid];
        //return tempaddress;



1) I have written a code in solidity clients is a array type which stores a address

2) Now my function MLMloyalityPoints will get pass in the id and i will pass the id to my clents[] array

3) I am expecting it will give a address with is at index at 0

4) Now i want to transfer value to that address by using transfer method i am getting error while intracting

5)Any suggestions in code i am thinking there is something wrong in transfer() method i refreed to many documention they say diffrence between send and transfer

  • Can you please explain what MLMloyaltyPoints is supposed to do?, also in your code clients is an array of addresses not uint256. What i understand is that you want to transfer 1000000000000000 wei to the clients in the array, right?, the things is that anyone with an Id can request recurrently the transfers. Please describe the expected functionality of the function MLMloyaltyPoints
    – Jaime
    Commented Nov 1, 2018 at 7:24
  • 1
    all the transfers are in Wei
    – Jaime
    Commented Nov 1, 2018 at 7:26
  • i want to ant to transfer 1000000000000000 wei to the clients in the array depending on the array on the id passed by the user Commented Nov 1, 2018 at 7:34
  • HI Jamie I have given refrence id's on the order .2) Who ever pays a payment with refrence id's get the the refreer will get some ether 3) in my function i want to do the same thing when the user passes the refreer id i want to give some wei Commented Nov 1, 2018 at 7:43
  • Ok I understand that those with the reference id will get paid, A final question, do you want to control that they do not use the same reference id to get paid twice or this is not important?
    – Jaime
    Commented Nov 1, 2018 at 7:45

1 Answer 1


All transactions are in wei.

This will work. The most probable reason for the error is that your contract doesn't have enough Ether.

mapping(uint256 => bool) public paid;

function MLMloyalityPoints(string _Compney_name,uint256 _refreeid) public payable {
    address  tempaddress = clients[_refreeid-1];
    //return tempaddress;
    paid[_refreeid] = true;

paid indicates if the user with the reference id_refreeid` has already claimed the ether.

Hope this helps

  • but jamie i have send some ether before to that contract because i have written plese look at the following link remix.ethereum.org/… Commented Nov 1, 2018 at 9:15
  • 1
    go it thanks i am sending less ether and asking for more ether Commented Nov 1, 2018 at 9:17
  • one small doubt but if another user enters the same refrence id he should get ether. one person shoudn't call the function two times ? the same refrence id must be paid how many times user enters Commented Nov 1, 2018 at 9:27
  • a reference id is paid only once, note that the references are tied to a single user. if another users enters a reference id that was already payed the contract will revert. notice that in yur current code anyone can request a reference Id and then go to the other function and get ether. I don't know if this is what you want. You could avoid the whole thing with the references by having a mapping that counts how many payments every subject can do. Also i think that giveRefrenceId should should have some kind of checking because as I said, anyone can get a referenceId
    – Jaime
    Commented Nov 1, 2018 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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