0

sorry to bother, trying to get an acknowledgment that my sender(msg.sender) address is sending to the receive() external payable. compiles fine, doesn't deploy correctly to show +1ETH in recipient wallet. How do I code that.

contract WagerAgreement { uint public value; address payable public Instigator; address payable public Rider;

enum State { Created, Sign, Locked, Release }
State state;

constructor () payable isInstigator { 
   Instigator = payable(msg.sender);
   value = msg.value;
}

receive() external payable{
    Instigator = payable(msg.sender);
    Rider = payable(msg.sender);
}

Example of function:

function WagerSent () external isInstigator inState(State.Created) payable {
    Instigator = payable(msg.sender);
    Rider = payable(msg.sender);
    state = State.Created;
}

// received and acknowledged by 'Rider' by showing a response - possibly by a boolean.

function RiderAccepts () external isRider inState(State.Sign) payable {
    Rider = payable(msg.sender);
    state = State.Sign;

How do I make sure that the Rider is receiving the value in their specific wallet? How do I import their wallet address? Is it possible to make it a variable to the Rider and not a constant?

Thank you.

2
  • 1
    Could you share the whole contract and add a bit more details? Aug 24, 2022 at 5:57
  • I am trying to create a contract where the 'Instigator' sends a value to the 'Rider'. The rider then accepts the contract by putting in half of the 'Instigator's amount. Once the real world action is complete, the 'Instigator and Rider' release funds. Sep 8, 2022 at 1:03

1 Answer 1

0

Please add more context to the issue you are facing.

However, The first thing you need to ensure is that you are reading the value from a valid ERC20 Interface passing in the token contract address to read the user's balance.

You can use the balanceOf(address) function on the IERC20 Interface to get the wallet balance. [https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#IERC20][1]

The receive function cannot take any extra arguments, you can only obtain msg.sender to get the sender address and msg.value to obtain the value the user has send to the recieve function.

[https://blog.soliditylang.org/2020/03/26/fallback-receive-split/][2]

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.