# Send a gasless transaction

Send a sponsored transaction from the terminal using Openfort's CLI. This walkthrough covers creating a backend wallet, registering a contract, setting up policies for both signing and gas sponsorship, and executing a gasless transaction.

## Prerequisites

* [Node.js](https://nodejs.org/) (v18+)
* An [Openfort](https://dashboard.openfort.io/) account with a project created

## Install the Openfort CLI

```bash
npm install -g @openfort/cli
openfort login
```

## Teach your agent to use Openfort

Register the CLI as an MCP server so your agent can call Openfort tools directly:

```bash
openfort mcp add
```

Or, if your agent supports skills:

:::code-group

```bash [Claude Code]
claude -p "Read https://github.com/openfort-xyz/agent-skills and set up Openfort CLI"
```

```bash [Amp]
amp --execute "Read https://github.com/openfort-xyz/agent-skills and set up Openfort CLI"
```

```bash [Codex CLI]
codex exec "Read https://github.com/openfort-xyz/agent-skills and set up Openfort CLI"
```

:::

## Walkthrough

::::steps

### 1. Set up backend wallet signing

Generate the signing keys that authorize your backend wallet to sign transactions:

> **Prompt your agent**: "Run `backend-wallet setup` to generate and register the ECDSA P-256 signing keys."

### 2. Create an EOA

Provision the wallet that will send the transaction:

> **Prompt your agent**: "Run `accounts evm create` to create a new EVM backend wallet. Note the account ID (`acc_...`) and address."

### 3. Register the target contract

Openfort validates that transaction targets are registered contracts. Register the contract you want to interact with:

> **Prompt your agent**: "Use `contracts create` to register USDC on Base Sepolia — name `USDC`, address `0x036CbD53842c5426634e7929541eC2318f3dCF7e`, chain ID `84532`."

:::info
Openfort auto-fetches the contract ABI from on-chain verification. For proxy contracts (like USDC), this may return the proxy ABI instead of the implementation ABI. If your transaction calldata targets implementation functions (e.g., `transfer`), provide the implementation ABI explicitly via the `--abi` flag.
:::

### 4. Create policies

You need two policies: one to **allow signing** and one to **sponsor gas**.

> **Prompt your agent**: "Create two project-scoped policies using `policies create`:
>
> 1. A signing policy with the rule `{"action":"accept","operation":"signEvmTransaction"}`
> 2. A sponsorship policy with the rule `{"action":"accept","operation":"sponsorEvmTransaction","criteria":[{"type":"evmNetwork","operator":"in","chainIds":[84532]}]}`"

Verify both policies are working with a pre-flight check:

> **Prompt your agent**: "Run `policies evaluate` for both `signEvmTransaction` and `sponsorEvmTransaction` operations to confirm they're allowed."

### 5. Create a fee sponsorship

Link a fee sponsorship to the sponsorship policy:

> **Prompt your agent**: "Run `sponsorship create` linked to the sponsorship policy ID from Step 4. Use the `pay_for_user` strategy and name it `Base Sepolia Gas Sponsor`."

The `pay_for_user` strategy means Openfort covers the gas fees entirely. Other strategies include `charge_custom_tokens` (user pays with ERC-20) and `fixed_rate`.

### 6. Send a gasless transaction

Execute the transaction. The `send-transaction` command auto-upgrades the EOA to an EIP-7702 Delegated Account if needed.

> **Prompt your agent**: "Use `accounts evm send-transaction` with the account ID from Step 2, chain ID `84532`, the sponsorship ID from Step 5 as the `--policy` flag, and an interactions array targeting the registered USDC contract."

The interactions array format is:

```json
[{"to": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "data": "0x<abi-encoded-calldata>", "value": "0"}]
```

Where `data` is the ABI-encoded function call (e.g., `transfer(address,uint256)` encoded as hex).

::::

## Next steps

* [Openfort CLI reference](/docs/overview/building-with-cli)
* [Gas sponsorship configuration](/docs/configuration/gas-sponsorship)
* [Gasless transactions on EVM](/docs/products/server/evm/gasless-transactions)
* [Policies overview](/docs/configuration/policies)
