My contract (contract A) is meant to send txs to another contract (Contract B). I want to end up having the fallback payable function of Contract B get called. I try to accomplish this by making a function in Contract A to take in an address (contract B address) and then transfer 0
eth to contract B from contract A.
function txTest(address recipient_addr) payable external
{
recipient_addr.transfer(0);
}
However this currently does not work even if the contract address I put in as the recipient_addr has a fallback payable function.
If I use another non contract address as the recipient_addr then transfer will go off without issue.
Is it possible to have Contract A manage to call Contract B's fallback payable function?
Thank you for the help.
EDIT: The actual fallback function that should be called.
function () external payable {
buyObject(msg.sender);
}
function buyObject(address _beneficiary) onlyValidPurchase
onlyBuyer(_beneficiary)
onlyValidAddress(_beneficiary) public payable {
uint numTokens = calculateTokens();
shopSettings.fundsRaised = shopSettings.fundsRaised.add(msg.value);
object.mint(_beneficiary, numTokens);
ObjectPurchase(msg.sender, _beneficiary, msg.value, numTokens);
forwardFunds();
}
recipient_adr
if it has one. If you're still having trouble, you'll need to share the full code (including the code behindrecipient_adr
) and how you're deploying the contract's and passing the address to this function, as well as the exact error you're seeing when you say it "does not work."recipient_addr.call.value(n)()
, where n is the amount of wei you want to send.