# Chainlink Code Walkthrough

By [Hicss](https://paragraph.com/@freesuton) · 2022-06-14

---

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](https://github.com/ethereum/EIPs/issues/20) 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](https://github.com/ethereum/EIPs/issues/223).

**How Chainlink works:**

![](https://storage.googleapis.com/papyrus_images/214f62883266baf309583fae6f072543aeffb6496d41492662281a947cf4da4c.png)

Code Flow:

![](https://storage.googleapis.com/papyrus_images/970d8ddc87216706cf7a2a8097cf200d8c0f528acbd460e6cfba62ed525bc8c9.png)

![](https://storage.googleapis.com/papyrus_images/6b1f4f568084ca6943a25882f06edd368d9b2652a277b9603fb5e76e2e3a457c.png)

---

*Originally published on [Hicss](https://paragraph.com/@freesuton/chainlink-code-walkthrough)*
