Kroma
GithubCommunity
  • Introduction
    • Overview
    • KRO Tokenomics
      • Token Allocation
      • Token Distribution
      • Token Utilities
      • Airdrops
        • Initial Airdrop
    • Official Links
  • BUILDERS
    • Developers
      • Contract Deployment Tutorial
        • Using Foundry
        • Using Remix IDE
        • Using Hardhat
      • JSON-RPC API
      • Oracles
    • Node Operators
      • Kroma MPT Migration Guide
      • Running a Full Node
      • Running a Kroma v2 Validator Node
        • How to Migrate Your Validator to KRO-based Validator System
      • How to Sync Blocks Using a Snapshot
      • FAQ
      • [Deprecated] Running a Kroma v1 Validator Node
        • How to Check and Claim the Validator Reward
    • Network Information
    • Protocol Contracts
    • Testnet
      • Setup
      • Faucet
      • Bridge
      • Contract Addresses
  • USERS
    • Wallet Configuration
    • Bridge
    • Block Explorer
    • How to Swap legacy USDC to upgradable USDC
  • Governance
    • Kroma Security Council
  • Kroma Guardian House
    • Overview
    • Philosophy
    • KRO & KGH NFT Staking
      • Validator Boosting by KGH NFT
      • How to Get KRO
      • FAQ
    • KGH NFT Migration & KYC
      • KGH NFT Migration
      • How to Complete KYC with Argos
    • KGH NFT Sales (Ended)
      • KGH Utilities
      • Referral Program: Expand Your Impact
      • Estimated Reward Value
    • Notice
  • Resources
    • Security
    • Brand Kit
    • FAQs
    • Glossary
Powered by GitBook
On this page
  • Foundry
  • Steps

Was this helpful?

  1. BUILDERS
  2. Developers
  3. Contract Deployment Tutorial

Using Foundry

This page describes how to deploy smart contracts using Foundry.

PreviousContract Deployment TutorialNextUsing Remix IDE

Last updated 10 months ago

Was this helpful?

Foundry

Foundry is a smart contract development toolchain. Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line and via Solidity scripts.

Foundry book, see:

Steps

  1. and .

  2. Create a project with Foundry, forge init and cd into it:

forge init hello_foundry
  1. Let's check out what forge generated for us:

cd hello_foundry
tree . -d -L 1
.
├── lib
├── script
├── src
└── test

We Can build the project with forge build :

forge build
[⠊] Compiling...
[⠰] Installing solc version 0.8.17
[⠊] Successfully installed solc 0.8.17
[⠊] Compiling 6 files with 0.8.17
[⠢] Solc 0.8.17 finished in 978.66ms
Compiler run successful

And run the tests with forge test :

forge test
[⠢] Compiling...
No files changed, compilation skipped

Running 2 tests for test/Contract.t.sol:TestContract
[PASS] testBar() (gas: 401)
[PASS] testFoo(uint256) (runs: 256, μ: 3425, ~: 3425)
Test result: ok. 2 passed; 0 failed; finished in 11.55ms
  1. Deploy the contract from your project, located at src/Counter.sol. Replace YOUR_PRIVATE_KEY with your private key, mentioned in the previous prerequisites section.

forge create --rpc-url {$RPC_URL} \
    --value {$LOCK_AMOUNT} \
    --constructor-args {$UNLOCK_TIME} \
    --private-key {$YOUR_PRIVATE_KEY} \
    --legacy \
    src/Counter.sol:Counter
  • --legacy flag means Use legacy transactions instead of EIP1559 ones. This is auto-enabled for common networks without EIP1559.

  • <unlock_time> is the Unix timestamp after which the funds locked in the contract will become available for withdrawal. Try setting this to some Unix timestamp in the future, like 1696118400 (this Unix timestamp corresponds to October 1, 2023).

  • <lock_amount> is the amount of test ETH to be locked in the contract. Try setting this to some small amount, like 0.0000001ether.

For information on additional flag options, follow this

https://book.getfoundry.sh/
Install Foundry
Node
link