# Data Functions

All data fetching results will return a `CircuitValue256`. If an input value is of type `string`, `number`, or `bigint`, it will be treated as a constant (regardless of the input to your circuit, it will need to remain the same). If you pass in a `CircuitValue` instead, it will be a variable input to your circuit. All inputs defined in the JSON input panel at the bottom of axiom-repl will be auto-converted to `CircuitValue`s (or `CircuitValue256` if it exceeds 253 bits) and injected into your circuit.

### Account Subquery

<pre class="language-typescript" data-full-width="false"><code class="lang-typescript"><strong>const account = getAccount(blockNumber, address)
</strong><strong>const nonce: CircuitValue256 = account.nonce()
</strong>const balance: CircuitValue256 = account.balance()
const storageRoot: CircuitValue256 = account.storageRoot()
const codeHash: CircuitValue256 = account.codeHash()
</code></pre>

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/account-subquery" %}
[account-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/account-subquery)
{% endcontent-ref %}

### Header Subquery

```typescript
const header = getHeader(blockNumber)
const parentHash: CircuitValue256 = header.parentHash()
const sha3Uncles: CircuitValue256 = header.sha3Uncles()
const miner: CircuitValue256 = header.miner()
const stateRoot: CircuitValue256 = header.stateRoot()
const transactionsRoot: CircuitValue256 = header.transactionsRoot()
const receiptsRoot: CircuitValue256 = header.receiptsRoot()
const difficulty: CircuitValue256 = header.difficulty()
const blockNumber: CircuitValue256 = header.number()
const gasLimit: CircuitValue256 = header.gasLimit()
const gasUsed: CircuitValue256 = header.gasUsed()
const timestamp: CircuitValue256 = header.timestamp()
const extraData: CircuitValue256 = header.extraData()
const mixHash: CircuitValue256 = header.mixHash()
const nonce: CircuitValue256 = header.nonce()
const baseFeePerGas: CircuitValue256 = header.baseFeePerGas()


//gets the 32 bytes chunk of logsBloom, idx in [0, 8)
const logsBloom: CircuitValue256 = header.logsBloom(bytes32Idx)

```

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/header-subquery" %}
[header-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/header-subquery)
{% endcontent-ref %}

### Solidity Nested Mapping Subquery

```typescript
const mapping: Mapping = getSolidityMapping(blockNumber, address, slot)

/**
* Retrieves the value of a specific key in the mapping.
*
* @param key - The key of the mapping. Can be string | number | bigint or
* can be CircuitValue | CircuitValue256
* @returns A `CircuitValue256` representing the value of the key in the mapping.
*/
const val: CircuitValue256 = mapping.key(key)

/**
* Retrieves the value of a specific set of keys in a nested mapping.
*
* @param keys - Each key can be string | number | bigint or
* can be CircuitValue | CircuitValue256
* @returns A `CircuitValue256` representing the value.
*/
const nestedVal: CircuitValue256 = mapping.nested([key1, key2, key3])
```

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/solidity-nested-mapping-subquery" %}
[solidity-nested-mapping-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/solidity-nested-mapping-subquery)
{% endcontent-ref %}

### Receipt Subquery

```typescript
const receipt: Receipt = getReceipt(blockNumber, txIdx);

const txType: CircuitValue256 = receipt.txType();
const blockNumber: CircuitValue256 = receipt.blockNumber();
const txIdx: CircuitValue256 = receipt.txIdx();

// gets the 32 bytes chunk of logsBloom, idx in [0, 8)
const logsBloom: CircuitValue256 = receipt.logsBloom(bytes32Idx)

// retrieves a log entry in the receipt
const log: Log = receipt.log(logIdx)

// gets the address from which the event was emitted from
const address: CircuitValue256 = log.address()

// gets the value of a log topic, with an event given by eventSchema
const topic: CircuitValue256 = log.topic(topicIdx, eventSchema)

// gets a 32 byte chunk of the logs data at the specified offset
const data: CircuitValue256 = log.data(bytes32Idx)
```

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/receipt-subquery" %}
[receipt-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/receipt-subquery)
{% endcontent-ref %}

### Transaction Subquery

```typescript
const tx: Tx = getTx(blockNumber, txIdx)

const chainId: CircuitValue256 = tx.chainId();
const nonce: CircuitValue256 = tx.nonce();
const maxPriorityFeePerGas: CircuitValue256 = tx.maxPriorityFeePerGas();
const maxFeePerGas: CircuitValue256 = tx.maxFeePerGas();
const gasLimit: CircuitValue256 = tx.gasLimit();
const to: CircuitValue256 = tx.to();
const value: CircuitValue256 = tx.value();
const data: CircuitValue256 = tx.data();
const gasPrice: CircuitValue256 = tx.gasPrice();
const v: CircuitValue256 = tx.v();
const r: CircuitValue256 = tx.r();
const s: CircuitValue256 = tx.s();

const type: CircuitValue256 = tx.type();
const blockNumber: CircuitValue256 = tx.blockNumber();
const txIdx: CircuitValue256 = tx.txIdx();
const functionSelector: CircuitValue256 = tx.functionSelector();

// retrieves a 32 byte chunk of the transaction calldata at a specified offset
const calldata: CircuitValue256 = tx.calldata(bytes32Idx);

// retrieves a 32 byte chunk of the transaction calldata if it was a contract
// deployment transaction
const contractData: CircuitValue256 = tx.contractData(bytes32Idx)
```

To find a the index of a transaction from its transaction hash, open up the transaction in Etherscan, and then click on more details. The txIdx is labeled "Position in Block":

<figure><img src="https://2736512689-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FypbpUjOqJ3jQY4bOzbnl%2Fuploads%2FI0Sj3aQebCEbS8FuN9Qw%2FScreenshot%202023-11-17%20at%2011.39.35%E2%80%AFAM.png?alt=media&#x26;token=1bbef577-c94f-4adc-b9f2-01a75e06b23f" alt=""><figcaption></figcaption></figure>

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/transaction-subquery" %}
[transaction-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/transaction-subquery)
{% endcontent-ref %}

### Storage Subquery

```typescript
const storage: Storage = getStorage(blockNumber, address)

// gets the value of the specified slot in the contract's storage
const slotValue: CircuitValue256 = storage.slot(slot);
```

See for more details and limitations:

{% content-ref url="../axiom-sdk-reference/data-subqueries/storage-subquery" %}
[storage-subquery](https://intrinsic-1.gitbook.io/axiomv2-sdk/sdk-and-repl-reference/axiom-sdk-reference/data-subqueries/storage-subquery)
{% endcontent-ref %}
