# Interact with Contracts

> Documentation index: [llms.txt](https://namera.ai/llms.txt).

Source: https://namera.ai/docs/cli/guides/transactions/interact-with-contracts

Encode a contract call and execute it through a session key.

Install the CLI and [sign in](https://namera.ai/docs/cli/authentication). Replace the example
account ID, session-key ID, and recipient with your own. Use an active key
installed on **Base Sepolia** with permission for the operation.

Confirm the contract address and ABI from the contract's publisher. The key must
allow the target and function. This example calls `setValue(uint256)` on a
contract you control.

## Encode Calldata [#encode-calldata]

```sh
npm install viem
```

```js title="encode-call.mjs"
import { encodeFunctionData, parseAbi } from "viem";

console.log(
  encodeFunctionData({
    abi: parseAbi(["function setValue(uint256 value)"]),
    functionName: "setValue",
    args: [42n],
  }),
);
```

## Simulate the Call [#simulate-the-call]

```sh
calldata=$(node encode-call.mjs)
namera execution simulate \
  --namespace evm \
  --wallet 0199dfe1-0000-7000-8000-000000000001 \
  --session-key 0199dfe1-0000-7000-8000-000000000002 \
  --network 'Base Sepolia' \
  --to <contract-address> \
  --value 0 \
  --data "$calldata"
```

<div className="docs-response">

```text
Transaction preview
-> Account: 👛 Example account
-> Network: Base Sepolia
-> Session key: Example session
-> Policy decision: Allowed
-> Calls: Succeeded

Simulation only. No transaction was submitted.
```

</div>

## Execute the Call [#execute-the-call]

Use the same calldata and contract only after reviewing the preview:

```sh
namera execution execute \
  --namespace evm \
  --wallet 0199dfe1-0000-7000-8000-000000000001 \
  --session-key 0199dfe1-0000-7000-8000-000000000002 \
  --network 'Base Sepolia' \
  --to <contract-address> \
  --value 0 \
  --data "$calldata" \
  --sponsor true
```

<div className="docs-response">

```text
-> Account: 👛 Example account
-> Network: Base Sepolia
-> Session key: Example session
-> Status: Queued
-> UserOp Hash: 0x1111111111111111111111111111111111111111111111111111111111111111

Not confirmed yet. Check again with:
  namera execution status 0199dfe1-0000-7000-8000-000000000003
```

</div>

Save the submission ID and [track it](https://namera.ai/docs/cli/guides/transactions/track-transactions).
Do not repeat the execution to check progress.

Example output uses fixture accounts and hashes, captured with the CLI's output
formatters. Plain-text output is shown without terminal colors; your values and
relative expiry dates will differ.
