> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dune.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sophon Call Tables

> On Dune, we parse all message calls and transactions made to smart contracts on the Sophon network in their own tables.

export const DuneEmbed = ({qID, vID, height = '500px'}) => <>
    <div className="hidden dark:block">
      <iframe src={`https://dune.com/embeds/${qID}/${vID}?darkMode=true`} style={{
  width: '100%',
  height,
  border: 'none',
  marginTop: '10px'
}}></iframe>
    </div>
    <div className="dark:hidden">
      <iframe src={`https://dune.com/embeds/${qID}/${vID}`} style={{
  width: '100%',
  height,
  border: 'none',
  marginTop: '10px'
}}></iframe>
    </div>
  </>;

## Overview

On Dune, we parse all message calls and transactions made to smart contracts in their own tables. This allows us to isolate the logic of a specific smart contract and analyze how it interacts with other smart contracts.

The data is stored in the format:

`[projectname_blockchain].[contractName]_call_[functionName]`

This allows us to analyze how a specific function is used in a smart contract, and how often it is called, as well as how it interacts with other smart contracts.

Call tables always originate from the `traces` table, which contains all the transactions and message calls on the Ethereum network. We parse the `data` field of the `traces` table to decode the function call and parameters.

## Decoding

When a transaction is sent to a smart contract on the Ethereum network, it contains a `data` field. This `data` field is the encoded function call and parameters. Dune decodes this data and stores it in the corresponding table.

For example, when a transaction is sent to the [Uniswap v3 factory](https://etherscan.io/address/0x1f98431c8ad98523631ae4a59f267346ea31f984#code) contract on the Ethereum network, Dune will decode the `data` field and store it in the table:

`uniswap_v3_ethereum.Factory_call_createPool`

<DuneEmbed qID="3456944" vID="5809273" height="300px" />

## Multiple Instances

For a contract where multiple instances exist, we will decode all calls to all instances of this smart contract into one table. If there are transactions calling the `swap` function of any instance of the [Uniswap v3 pair](https://etherscan.io/address/0x8f8ef111b67c04eb1641f5ff19ee54cda062f163#writeContract) contract, we will decode this data into the table `uniswap_v3_ethereum.Pair_call_swap`. The `pair` contract is a template contract and there are many instances of it, each with its own address. The column `contract_address` will indicate the address of the instance of the pair contract that was called.

<DuneEmbed qID="3456960" vID="5809303" height="300px" />

## Common misconceptions

One thing to keep in mind here is that [web3.js](https://web3js.readthedocs.io), [web3.py](https://web3py.readthedocs.io/en/stable) and all other methods of (locally) calling a `pure`, `read`, or `constant` function do not broadcast or publish anything on the blockchain and are therefore not recorded in Dune.

However, if one of these functions is invoked by another smart contract in the context of a transaction, this will be broadcast on the chain and therefore accessible in Dune.

In short: **State data stored in the memory of a smart contract is not available on Dune!**

A good example of this is the function `decimals` of the [erc20 token contract](https://etherscan.io/token/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984#readContract) `Uni` which is a `constant` state variable that is able to be accessed through an automatically created "[getter function](https://docs.soliditylang.org/en/v0.7.4/contracts.html#getter-functions)". Should a smart contract invoke this function in the context of transaction, this message call will be recorded in the Dune table [`uniswap."UNI_call_decimals"`](https://dune.com/queries/741354).

This is in contrast to anyone calling this function locally using web3.py/web3.js or using the Etherscan frontend to access this state. These local calls are not recorded in Dune.

## Further Reading

<CardGroup cols={3}>
  <Card title="What is the difference between a transaction and a call?" icon="phone" iconType="duotone" href="https://ethereum.stackexchange.com/questions/765/what-is-the-difference-between-a-transaction-and-a-call" />

  <Card title="Soliditylang.org documentation" icon="book" iconType="duotone" href="https://docs.soliditylang.org/en/v0.8.13/contracts.html#function-visibility" />

  <Card title="How Calldata is Encoded" icon="database" iconType="duotone" href="https://degatchi.com/articles/reading-raw-evm-calldata" />
</CardGroup>
