Skip to main content
Testnetly

All posts

Deploy your first smart contract on a testnet: tools, verification, key safety

What deploying a contract is, where the official Remix, Foundry and Hardhat quick starts are, how to verify the contract on a block explorer, and the mistakes that leak a private key into files, repositories and chats.

By Testnetly Editorial8 min read

Branded Testnetly cover on a navy background with the title "Deploy your first smart contract on a testnet: tools, verification, key safety" and the Testnetly mark

"Deploy a contract" is a common testnet task, and for many people it is the first time they use a developer tool. It is also a task where a private key can end up in a file, a terminal or a public repository. This post explains what deployment is, where the official quick starts for three common tools are, how to verify a contract on an explorer, and which mistakes leak a key. The tools and wallets are named as examples, not recommendations. It contains no code. Follow each tool's own documentation for the commands, because they change between versions.

What deployment is

Ethereum.org describes a smart contract as "simply a program that runs on the Ethereum blockchain" (ethereum.org: smart contracts). Deploying is how that program gets onto a network: "To deploy a smart contract, you merely send an Ethereum transaction containing the compiled code of the smart contract without specifying any recipient." (ethereum.org: deploying).

  • You need compiled code. Contracts are written in a language such as Solidity and then compiled. Ethereum.org: "For the EVM to be able to run your contract it needs to be in bytecode." (ethereum.org: compiling).
  • You need gas. The deploying page lists "ETH for gas" and warns that "contract deployment needs a lot more gas than a simple ETH transfer". On a testnet that means faucet tokens, as in our testnet faucet guide.
  • You need a connection to the network. The page lists "access to an Ethereum node, either by running your own, connecting to a public node, or via an API key using a node service".

See also common testnet tasks.

Before you start

  1. A wallet used only for testing. Deployment can put a private key near files and terminals. Use the wallet from setting up a separate wallet, never a wallet that holds anything of value.
  2. Test tokens on the right network. Check the network name and chain ID in the project's docs.
  3. The project's own instructions. Some testnets need special compiler settings or their own tool versions.

Route 1: Remix, in the browser

Remix is an editor that runs in a web page, so nothing has to be installed. Its documentation has a page called "Creating and Deploying a Contract" (Remix docs). The steps are:

  1. Create a file for the contract and paste or write the code.
  2. Compile it in the Solidity compiler panel.
  3. Choose an environment. This choice decides where the contract goes.
  4. Press deploy, and confirm the transaction if a wallet asks.

The environment is the part to understand. The docs list several. Two matter here:

  • "Remix VM is a test blockchain in the browser." It runs in the browser, and the docs note that reloading the page resets it.
  • "Injected Provider is used to connect Remix with a Browser Wallet (e.g. MetaMask) which is generally for deploying to a public network." With this option, the contract goes to whichever network your wallet is set to.

A testnet task needs the second, with the wallet on the project's testnet.

Here your wallet signs the transaction, so you never copy a private key anywhere. In our view, signing in a browser wallet is the safest way to do a first deploy.

Route 2: Foundry, on the command line

Foundry is a set of command-line tools. Its deployment guide has a section called "Testnet deployment" with three steps (Foundry: deploying contracts):

  1. Create an encrypted keystore.
  2. Deploy to a testnet.
  3. Verify the contract.

The first step is the one that matters for safety. The guide says: "Never use plaintext private keys." You import the key into an encrypted keystore once, protect it with a password, and then refer to the account by name.

Route 3: Hardhat, in a project folder

Hardhat is a development environment that runs in a project folder. Its tutorial has a page on deployment that uses what it calls "our official deployment plugin" (Hardhat tutorial: deploying). The page moves from a simulated network, to a local node, to a live testnet. For the last step it says: "Make sure you have an RPC URL and an account with some Sepolia ETH in it."

The tutorial first shows the private key written directly in the config file, then warns: "This example puts sensitive information like private keys directly in the config file, which is a security risk. This is only done here for learning purposes."

The next tutorial page fixes it: "Hardhat includes a plugin to securely store and retrieve these values in a local keystore." (Hardhat tutorial: configuration variables). Do that page before you deploy anywhere public.

Verify the contract on an explorer

After a deploy, the explorer shows the contract's address but not its readable code. Hardhat's tutorial explains: "Etherscan only showed you the raw bytecode of the contract. To see its source code, you need to verify it." (Hardhat tutorial: verifying).

Ethereum.org defines what verification gives you: "Source code verification assures users and developers that the published contract code is the same code running at the contract address on the Ethereum blockchain." (ethereum.org: verifying). The page names Etherscan, Blockscout and Sourcify as verification services.

With Remix, Etherscan's docs describe a contract verification plugin: you choose the chain, the contract address and the contract name (Etherscan docs: verify with Remix). With Foundry and Hardhat, verification is a step in the guides linked above.

Three practical notes:

  • Use the explorer the project names. A new testnet may have its own explorer, and verification has to happen there. See our block explorer guide.
  • An explorer API key is not a wallet key. Etherscan's page says its plugin "requires an API key". That key is for the explorer's service, not for your wallet.
  • Verified does not mean safe. Ethereum.org separates source code verification from formal verification, which is about whether a contract behaves as expected. A verified contract only shows that the published code matches what was deployed.

Then record the contract address, the deploy transaction and the verification link in your hunting log.

The mistakes that leak a private key

  1. Writing the key in a config file. This is the shortcut Hardhat's tutorial warns about. Use the tool's keystore.
  2. Putting the key in an environment file. Foundry's guide on secrets says: "Do not put private keys in .env." (Foundry: keeping secrets out of plaintext).
  3. Pushing the project to a public repository. Hardhat's guide lists private keys among the values that should not be committed to shared repositories (Hardhat guide). GitHub's own advice for a leaked secret is that "as a first step you need to revoke and/or rotate that secret" (GitHub docs). Our view: a wallet's private key cannot be rotated, so treat a leaked key as lost and move to a new account.
  4. Exporting the key from your main wallet. MetaMask's help page says: "Exporting your account could be risky as it displays your private key in clear text." (MetaMask: export a private key). If a tool needs a key, give it the testing wallet's key only, and "make sure no one else sees or is able to capture a screenshot while you retrieve your private key".
  5. Pasting the key to get help. MetaMask's rule has no exceptions: "You should never share your private key with anyone, including the MetaMask team." Nobody needs your key to debug a failed deploy.
  6. Running a script you did not read. A stranger's deploy script may read files on your machine. Use the project's official repository, reached from its official site.

What the task does and does not mean

A deploy task tests that a network's tools work for developers. Repeating it from many wallets to look like many users is what projects filter out, as covered in what Sybil detection is. Completing the task promises nothing. Any reward depends on the project's own published terms.

Checklist

  1. Testing wallet only.
  2. Faucet tokens on the network the docs name.
  3. First deploy with a browser wallet, so no key is copied.
  4. If a command-line tool needs a key, use its encrypted keystore.
  5. Keep keys out of config files, environment files and repositories.
  6. Verify on the explorer the project names.
  7. Never share a key or seed phrase with anyone.

Sources

Last checked: 28 November 2026.

Not financial advice. Testnetly does not guarantee rewards.

About the author

Testnetly Editorial

Guides and explainers from the Testnetly team, checked against official project sources before publication.