deploying-contracts-on-abstract
Deploying Contracts on Abstract
Default: Foundry. Abstract uses the ZK Stack VM — contracts must be compiled with zksolc, not standard solc. For Hardhat, see references/hardhat.md. For EVM differences, see references/evm-differences.md.
Foundry Setup
1. Install foundry-zksync
curl -L https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/install-foundry-zksync | bash
foundryup-zksync
Warning: This overwrites standard Foundry. Switch back with
foundryupif needed.
2. Create project
forge init my-abstract-project && cd my-abstract-project
3. Configure foundry.toml
[profile.default]
src = 'src'
libs = ['lib']
fallback_oz = true
is_system = false
mode = "3"
[etherscan]
abstractTestnet = { chain = "11124", url = "https://api-sepolia.abscan.org/api", key = "${ABSCAN_API_KEY}" }
abstractMainnet = { chain = "2741", url = "https://api.abscan.org/api", key = "${ABSCAN_API_KEY}" }
4. Compile
forge build --zksync
Outputs to zkout/ (not out/).
Deploy
Store private key securely
cast wallet import myKeystore --interactive
Fund the deployer
- Testnet: Claim from faucets or bridge from Sepolia
- Mainnet: Bridge ETH via Abstract Bridge
Deploy + verify (testnet)
forge create src/Counter.sol:Counter \
--account myKeystore \
--rpc-url https://api.testnet.abs.xyz \
--chain 11124 \
--zksync \
--verify \
--verifier etherscan \
--verifier-url https://api-sepolia.abscan.org/api \
--etherscan-api-key ${ABSCAN_API_KEY}
Deploy + verify (mainnet)
forge create src/Counter.sol:Counter \
--account myKeystore \
--rpc-url https://api.mainnet.abs.xyz \
--chain 2741 \
--zksync \
--verify \
--verifier etherscan \
--verifier-url https://api.abscan.org/api \
--etherscan-api-key ${ABSCAN_API_KEY}
Constructor arguments
Append --constructor-args <arg1> <arg2> in the order defined in the constructor.
Verify an Existing Contract
forge verify-contract <address> src/Counter.sol:Counter \
--chain 11124 \
--etherscan-api-key ${ABSCAN_API_KEY} \
--zksync
Use --chain 2741 for mainnet. Chain names (abstract-testnet, abstract) also work.
Testing
forge test --zksync
Fork testing against live networks:
forge test --zksync --fork-url https://api.testnet.abs.xyz
Local node:
anvil-zksync
forge test --zksync --fork-url http://localhost:8011
Cheatcode limitation: On Abstract's ZK VM, cheatcodes (
vm.prank,vm.roll, etc.) only work at the root test level — not from within contracts being tested.
Decision: Foundry vs Hardhat
| Scenario | Use |
|---|---|
| Solidity-first, fast iteration | Foundry (default) |
| TypeScript preference | Hardhat (references/hardhat.md) |
| Existing Hardhat project | Hardhat (references/hardhat.md) |
| Existing Foundry project | Foundry |
| Need JS plugin ecosystem | Hardhat (references/hardhat.md) |
Gotchas
- All
forgecommands need--zksync— without it, you get standard EVM bytecode that won't run on Abstract foundryup-zksyncoverwrites standard Foundry — usefoundryupto switch back- Abscan API key required — get one from abscan.org; set via
export ABSCAN_API_KEY=<key>or.env zkout/notout/— compiled artifacts go to a different directory- Never commit private keys — use
cast wallet importor environment variables
More from abstract-foundation/abstract-skills
using-agw-mcp
Give AI agents wallet capabilities on Abstract via the Abstract Global Wallet MCP server — read chain data, check balances, and (coming soon) send transactions on behalf of users. This skill should be used when setting up agw-mcp, giving AI agents wallet access on Abstract, or building MCP-powered agent workflows that interact with Abstract chain data.
3erc8004-on-abstract
Register AI agents, track reputation, and discover agents on Abstract using ERC-8004 — the onchain identity and reputation protocol for trustless agent economies. This skill should be used when registering an agent onchain, querying agent reputation, giving feedback to an agent, working with IdentityRegistry or ReputationRegistry on Abstract, ERC-8004, agent discovery, or onchain agent identity.
3abstract-global-wallet
Integrate Abstract Global Wallet (AGW) into React applications — email/social/passkey login, smart contract wallet, session keys, gas sponsorship, and wallet provider integrations for the Abstract Ethereum L2. This skill should be used when working with AGW, AbstractWalletProvider, useLoginWithAbstract, useAbstractClient, useWriteContractSponsored, agw-react, agw-client, create-abstract-app, session keys on Abstract, or gas-sponsored transactions on Abstract.
3myriad-on-abstract
Integrate Myriad Protocol prediction markets on Abstract — REST API for market data, polkamarkets-js SDK for trading outcome shares, builder revenue sharing via referralBuy, and contract addresses. This skill should be used when working with Myriad API, prediction markets on Abstract, polkamarkets-js SDK, trading or buying/selling prediction shares, builder codes, referralBuy, claiming winnings, Myriad contract addresses, or Myriad Protocol integration.
3connecting-to-abstract
Abstract network configuration — chain IDs, RPC endpoints, WebSocket URLs, block explorers, and wallet setup for the Abstract Ethereum L2. This skill should be used when configuring clients, wallets, or dev environments for Abstract, including questions about Abstract RPC URLs, chain IDs (2741/11124), testnet config, Abscan explorer, connecting to the Abstract network, or importing abstract/abstractTestnet from viem/chains.
3safe-multisig-on-abstract
Create and manage Safe multi-signature wallets on Abstract — deploy new Safes, configure owners and thresholds, propose and execute multi-sig transactions using the Safe SDK or the Safe UI. This skill should be used when working with Safe on Abstract, creating a multisig wallet on Abstract, safe.abs.xyz, Safe Protocol Kit on Abstract, multi-sig transactions, SafeL2, SafeProxyFactory, or managing shared wallets with multiple signers on Abstract.
3