I have two Contracts, Domain
and Serial
deployed separately.
NOTE: Most of the code is ommited for simplicity.
contract Serial {
Domain DOMAIN; //Domain contract is imported and set by another function
function payToSerial(string memory serialNumber, unit amount) public {
address toAddr = serialToAddress(serialNumber) //We convert serial number to a valid address
DOMAIN.transfer(toAddr, amount) //Use transfer() from *Domain* contract
}
}
contract Domain {
function transfer(address recipient, uint256 amount) public {
//does transfer under specific conditions,
}
}
When I call transfer() from Domain
contract it works, sends the funds from my wallet to whichever address I had specified.
However, when I call payToSerial() function which in turn calls the transfer() function from Domain
contract (as shown in code) the transaction fails because it is trying to send funds from the Serial
contract's address and not my wallet.
Is there way to modify payToSerial() function to cuurumvent this?
//
//
//
I tried to edit payToSerial() to accomplish that (To inherent msg.sender), but it did not work.
function payToSerial(string memory serialNumber, uint amount) public {
DOMAIN = Domain(msg.sender);
address toAddr = serialAddresses[serialNumber];
DOMAIN.transfer(toAddr, amount);
}
I am not sure if what I am trying to do is even possible, but I wanted to ask in any case.