Prerequisite knowledge:
ERC-667:
Allow tokens to be transferred to contracts and have the contract trigger logic for how to respond to receiving the tokens within a single transaction.
This adds a new function to ERC20 token contracts, transferAndCall
which can be called to transfer tokens to a contract and then call the contract with the additional data provided. Once the token is transferred, the token contract calls the receiving contract's function onTokenTransfer(address,uint256,bytes)
and triggers an event Transfer(address,address,uint,bytes)
, following the convention set in ERC223.
How Chainlink works:
Code Flow: