Developers

Deploy a contract

Point Foundry or Hardhat at the chain, deploy, and check it landed.

Deploy a contract

L2 Protocol is an EVM chain, so deploying here is the same as deploying to any Ethereum-compatible network. Point your tooling at the endpoint, fund the deployer, deploy, verify.

Nothing about the chain is special from a contract's point of view. Solidity is Solidity, the opcodes are the opcodes, and the tooling you already use works unchanged.

What you need

The network settings, which are in RPC and networks: chain id 12216 and https://rpc.l2protocol.com. Read them from the chain feed if your tooling can, so a second chain does not need a second copy of your setup.

A funded deployer account. Deployment is a transaction and costs gas like any other. Contract creation costs considerably more gas than a transfer, because the bytecode is written into the chain's state, but at 0.1 gwei it is still a small number. See Gas and transaction fees.

A private key you are willing to have on a machine, or a hardware wallet if the deployer holds anything worth stealing. Never a key that also holds funds you care about.

Foundry

# foundry.toml
[rpc_endpoints]
l2protocol = "https://rpc.l2protocol.com"
forge create --rpc-url l2protocol \
  --private-key $PRIVATE_KEY \
  src/MyContract.sol:MyContract

Hardhat

networks: {
  l2protocol: {
    url: "https://rpc.l2protocol.com",
    chainId: 12216,
    accounts: [process.env.PRIVATE_KEY]
  }
}
npx hardhat run scripts/deploy.js --network l2protocol

Check it landed

Every deployment produces a transaction, and that transaction has a page on the explorer showing the address of the contract it created.

curl -s 'https://l2pscan.com/api/explorer/transactions/<hash>'

Or open the hash on l2pscan.com, where the Contract created field links straight to the new address. See Reading a transaction page.

Verify it, immediately

Deployment puts machine code on the chain. Until you publish the source, nobody can read what your contract does, and nobody can call it from the explorer.

Verifying takes a minute and it is free. Do it while the build is still on the machine that produced it, because the exact compiler version and settings are what the check needs, and those are easiest to find now rather than in three months.

Verify your contract walks through it, including where Hardhat and Foundry keep the Standard JSON Input you need.

A few things worth knowing

There is no faucet. The chain has no test faucet, so a deployer account needs real L2P. Deployment costs little, but it is not nothing.

Anyone can call your contract. A public chain means every function you expose is callable by anyone who knows the address, verified or not. Access control is your job and nothing about the chain does it for you.

The block gas limit applies to deployment too. A contract too large to fit in a block cannot be deployed, and the usual EVM contract size limit applies. If you are near it, split the contract or use libraries.

Deployments are permanent. There is no undeploy. A contract without an upgrade path or a way to pause it is what it is, forever, at that address.

Use a proxy only if you mean it. An upgradeable contract means somebody can change what it does after people have trusted it. That is sometimes right and sometimes exactly what your users are afraid of. If you do use one, verify the implementation at its own address as well; the explorer marks proxies and points its read and write tabs at the implementation.

Talking to it afterwards

Once verified, the explorer gives you a read and write interface for free, which is often enough to check a deployment without writing a script. The ABI also becomes available through the API, so your own tooling can decode the events and calls of your contract. See The explorer API.