Deploying a Contract Using Foundry
Foundry is a Rust-based Ethereum development tool that enables developers to manage Solidity dependencies, compile and test smart contracts, deploy them, and interact with the blockchain through a command-line interface (CLI).
This guide outlines the process of building a Wallet dApp using Foundry and the dKargo Warehouse Testnet.
STEP 1 - Get Started with Foundry
To install Foundry, run the following command:
Installing Foundry is simple.
Linux or MacOS
curl -L <https://foundry.paradigm.xyz> | bash foundryupWindows
curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs/> | sh cargo install --
git <https://github.com/foundry-rs/foundry> foundry-cli anvil --bins --lockedSTEP 2 - Set Up Foundry Project
After installing Foundry, the next step is to initialize a new project.
mkdir helloDka
cd helloDka
forge init .Below is an example of the Foundry project folder structure.
/helloDka
├── README.md
├── foundry.toml
├── lib
|  └── forge-std
├── script
|  └── Counter.s.sol
├── src
|  └── Counter.sol
└── test
   └── Counter.t.solStep 3 - Example Contract: Counter.sol
Counter.solA newly created Foundry project includes a sample contract (counter.sol) along with a sample test file by default. The counter.sol contract implements a simple function to set the number variable.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract Counter {
    uint256 public number;
    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }
    function increment() public {
        number++;
    }
}
Step 4 - Compiling the Contract
If the contract compiles without errors, it is valid and ready for deployment on Warehouse.
forge buildStep 5 - Deploying the Contract on Warehouse
Deploying a contract can be easily completed with a single Forge CLI command.
However, this process requires:
The Warehouse RPC endpoint
A private key with sufficient $DKA for transaction fees
Use the provided RPC endpoint URL and ensure the private key is ready before proceeding.
Warehouse RPC Endpoint : https://it-full.dknote.net
forge create --rpc-url "<https://it-full.dknote.net>" --private-key YOUR_PRIVATE_KEY  src/Counter.sol:CounterUpon successful execution, the following response will be displayed:

The contract has been successfully deployed on dKargo’s Warehouse testnet.
Copy the contract address specified in "Deployed to", and use it to search for deployment details on dScanner.
Last updated