> For the complete documentation index, see [llms.txt](https://docs.rome.builders/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rome.builders/rome-academy/03-first-contract-on-hadrian.md).

# 3. Your first contract on Hadrian

Connect a wallet to Hadrian, fund it, deploy a contract with Hardhat, and follow your transaction to the Solana transaction that settled it.

You deploy a small Solidity contract to Hadrian, Rome's public testnet. The deploy is ordinary Hardhat. What is new is that you pay gas in USDC, and that the explorer links you to the Solana side of what you did.

## What you'll learn

* How to point a wallet and Hardhat at Hadrian.
* Why gas is USDC, and how a wallet gets it.
* Why a write on Rome costs more gas than Ethereum habits suggest.
* How to read your transaction on the Via explorer, and follow it to the Solana transaction that settled it.
* How to verify your source so the explorer shows it.

## Before you start

You have read [lesson 2](https://docs.rome.builders/rome-academy/02-what-you-can-build.md), which shows what this contract is the first step toward. Have these ready:

* Node.js at the version the [Quickstart](https://docs.rome.builders/getting-started-1/quickstart.md) lists.
* MetaMask installed.
* A new account, or a throwaway key. You export its private key into your shell, so do not use a key that holds real funds.
* A Solana wallet set to Devnet, only if you fund from Solana.

## The path

### Step 1. Add Hadrian to your wallet

Hadrian is a standard EVM network. You add it to MetaMask by hand with a name, RPC URL, chain id, currency symbol and explorer URL. Take every value from the table in [Quickstart, step 1](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-1.-add-hadrian-to-metamask). The values are also on [Hadrian](https://docs.rome.builders/networks/hadrian.md). Set the currency symbol to `USDC`.

Hardhat needs the same chain id and RPC URL. You put them in its config in step 3.

### Step 2. Fund the wallet

Gas on Hadrian is USDC, backed by Circle's Solana Devnet USDC. SOL is not the gas token. There is no Rome faucet. You get test USDC elsewhere and bring it in with the Rome Bridge. A deposit that arrives through the bridge lands as gas by default. Leave the bridge page's receive choice on gas.

There are two sources:

* **From Solana Devnet.** Take devnet USDC from the Circle faucet and a little devnet SOL for Solana fees. Bridge the USDC with its Solana route, and give your EVM address as the recipient. The bridge asks your EVM wallet to sign a claim transaction on Hadrian, and that turns the USDC into gas.
* **From an EVM testnet.** Mint test USDC on Ethereum Sepolia, and bridge it in. You need a little Sepolia ETH to pay the source-side transaction.

The steps and the faucet links are in [Quickstart, step 2](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-2.-fund-your-wallet), [Fund a wallet on Hadrian](https://docs.rome.builders/networks/hadrian.md#fund-a-wallet) and [Faucets](https://docs.rome.builders/resources/faucets.md). The bridge itself is on [Rome Bridge](https://docs.rome.builders/apps-on-rome/bridge-api.md).

How much to fund? The Quickstart gives a minimum and a comfortable amount. Read it before you start.

Check the balance in MetaMask before you go on. If it shows zero, the transfer has not finished. The bridge page shows each step and the expected time.

### Step 3. Create the Hardhat project

Create a Hardhat 3 project with the TypeScript and viem template. Then add a `hadrian` entry under `networks` with the chain id and RPC URL from the Hadrian page. The private key comes from an environment variable or from Hardhat's encrypted keystore. Prefer the keystore for anything beyond a throwaway key.

The exact commands and config are in Quickstart, [step 3](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-3.-create-a-hardhat-project) and [step 4](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-4.-configure-hardhat-for-rome). [Deploy Solidity Contracts](https://docs.rome.builders/developer-guides/deploy-solidity.md#hardhat) shows the full config file, and the [same flow in Foundry](https://docs.rome.builders/developer-guides/deploy-solidity.md#foundry).

### Step 4. Write and deploy the contract

The Quickstart contract, `HelloRome`, is deliberately plain. It stores a greeting, counts calls to `greet()`, and emits an event. Nothing in it is specific to Rome.

That is the point of this step: `HelloRome` deploys without changes. Before you port another contract, check [Known limitations](https://docs.rome.builders/security/known-limitations.md) for unsupported opcodes and gas differences. Write it, then run the deploy script against `hadrian`. The script deploys, calls `greet()` once, and reads the counter and greeting back. Copy both from Quickstart, [step 5](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-5.-write-a-contract) and [step 6](https://docs.rome.builders/pages/po4AvSyLswMyalsvyoEK#id-6.-deploy).

When it succeeds you have a contract address and a counter of 1.

### Step 5. Understand what it cost

The deploy used far more gas than the same contract would on Ethereum. Most of a write's gas on Rome pays for creating Solana accounts. A deployed contract creates new accounts for its code and storage. So does a transfer to a recipient that has never been used, and so does a new token account.

Two rules follow:

* Let your tooling estimate gas with `eth_estimateGas`. Hardhat, `forge create` and `cast send` do. `forge script` needs `--skip-simulation` to do the same.
* Never hardcode 21,000. A write that creates accounts, such as a deploy or a transfer to a never-used address, fails with a limit that low.

Rome charges the gas a transaction actually uses, so a high estimate costs you nothing. Keep the margin your tooling adds: for a call into a Solana program the estimate can come out low. [JSON-RPC Support](https://docs.rome.builders/reference/json-rpc.md#gas-is-solana-derived-estimate-dont-hardcode) has measured numbers for real writes.

### Step 6. Read it on the explorer

Open the Via explorer for Hadrian and look up your contract address. Its page links the creation transaction and lists the `greet()` call among its transactions. The explorer link is on [Hadrian](https://docs.rome.builders/networks/hadrian.md).

Via shows the usual EVM view: block, sender, gas used, event logs. Its "Settled in" row holds the signature of the Solana transaction that settled yours. Open that link. The Solana explorer shows that transaction's instructions, the programs it touched and the compute units it consumed. [Via Explorer](https://docs.rome.builders/apps-on-rome/via.md) explains what else Via shows.

Read the compute units there, not from `gasUsed`. On Rome, `gasUsed` is not a faithful measure of Solana compute.

### Step 7. Verify the source

Verification publishes your source and ABI, and the explorer then shows a "Source verified" badge. Rome runs a hosted Sourcify service, so the standard Hardhat and Foundry verify flows work. You point them at Rome's verifier and give the chain id.

The endpoints are under [Verifier endpoint](https://docs.rome.builders/developer-guides/verify-contracts.md#verifier-endpoint), and the config and commands are in the [Hardhat](https://docs.rome.builders/developer-guides/verify-contracts.md#hardhat) section. Use the testnet verifier for Hadrian. The mainnet verifier is a different URL, which matters in lesson 11.

## Check yourself

Your outcome: open your contract on the Hadrian explorer and see all three of these.

* Your deploy transaction, with its "Settled in" Solana signature, and that Solana transaction's instructions on the Solana explorer.
* A second transaction, the `greet()` call, with one event log from your contract address. That log is the `Greeted` event; its first topic is the hash of `Greeted(address,uint256)`.
* A "Source verified" badge on the contract.

If you are stuck, the common errors are in the [Quickstart](https://docs.rome.builders/getting-started-1/quickstart.md#common-errors). The usual one is `insufficient funds`, which means the wallet holds too little USDC for the gas limit times the gas price.

Then answer these.

1. Why is a first deploy so much more expensive in gas than on Ethereum?
2. Where do you read a transaction's Solana compute units: `gasUsed`, or the Solana transaction that Via links to?
3. Is the testnet USDC you used worth anything?

<details>

<summary>Answers</summary>

1. Most of the gas pays for creating Solana accounts: the contract, its storage, and any new token accounts.
2. The Solana transaction. Via links it from the "Settled in" row, and the Solana explorer shows its compute units. `gasUsed` is not a faithful proxy.
3. No. Hadrian settles on Solana Devnet, so its USDC and SOL are not real money.

</details>

## Next

[Register your app in Arena](https://arena.mainnet.romeprotocol.xyz/apps/new) and link this Hadrian contract to it. The app moves to Building.

[4. How Rome runs your code](https://docs.rome.builders/rome-academy/04-how-rome-runs-your-code.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rome.builders/rome-academy/03-first-contract-on-hadrian.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
