I have two contracts, contract A represents Token A, contract B is its own contract. I users to call a contract B function by paying Token A to contract B, as if they were using a payable function, but by paying Token A instead of ETH.

Is making the user call token.approve() on contract A and then token.transferFrom() on contract B a safe solution or is there a pattern I should follow?


You should look into ERC777 standard for your requirements.

It defines advanced features to interact with tokens. Namely, operators to send tokens on behalf of another address—contract or regular account—and send/receive hooks to offer token holders more control over their tokens.

this might help: ERC777 with ERC20 backward compatibility and ERC777 implementation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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