For the complete documentation index, see llms.txt. This page is also available as Markdown.

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, which shows what this contract is the first step toward. Have these ready:

  • Node.js at the version the Quickstart 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. The values are also on Hadrian. 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, Fund a wallet on Hadrian and Faucets. The bridge itself is on Rome Bridge.

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 and step 4. Deploy Solidity Contracts shows the full config file, and the same flow in 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 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 and step 6.

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 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.

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 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, and the config and commands are in the 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. 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?

Answers
  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.

Next

Register your app in Arena and link this Hadrian contract to it. The app moves to Building.

4. How Rome runs your code

Last updated

Was this helpful?