Just learning Solidity here. I am trying to pass an receiving address, and an arbitrary amount (other than msg.value) to my transfer function, but it is just not working for me. This is the code:
pragma solidity 0.8.7;
contract TestingTransfer{
uint approvalCount = 1;
uint approvalMinimum = 2;
uint originalAmount;
address payable originalReceiver;
constructor(address payable _oRec, uint _oA){
originalReceiver = _oRec;
originalAmount = _oA;
}
function approveTransferRequest() public payable {
approvalCount += 1;
if(approvalCount >= approvalMinimum){
(bool success, ) = originalReceiver.call{value: msg.value}("");
require(success, "Failed to transfer the funds, aborting.");
}
}
}
Ok, so that code works great when I use the remix value input box, and manually enter whatever eth amount I want to transfer. However, my endgoal is to have the if statement produce this:
function approveTransferRequest() public payable {
approvalCount += 1;
if(approvalCount >= approvalMinimum){
(bool success, ) = originalReceiver.call{value: originalAmount}("");
require(success, "Failed to transfer the funds, aborting.");
}
}
Where the argument for the call method is 'originalAmount' which was passed from another function. However, the compiler does not like this, and reverts my function every time.
I'd appreciate any suggestions :)