dKargo Docs
dKargo.ioWhitepaper
Docs ENG
Docs ENG
  • Welcome to dKargo
  • Run dKargo Node
    • Chain RPC
    • Installation Guide
    • Types of Chain Node
    • Full Node
    • Archive Full Node
    • Validator Node
  • Wallet Setup
    • Connectiong to MetaMask
    • Creating a wallet
    • Importing a Wallet
    • Adding the dKargo Network
  • Validator Operations
    • Validator Staking
    • Staking
    • Unstaking
    • Claim
  • Deploy Contract
    • How to deploy a contract
    • Deploying a Contract Using Remix-IDE
    • Deploying a Contract Using Hardhat
    • Deploying a Contract Using Foundry
  • ERC-20 BRIDGING
    • ERC-20 Bridging
    • Standard Gateway
    • Generic-custom Gateway
    • Custom Gateway
  • DKA Bridging
    • DKA Bridging
    • DKA Deposit
    • DKA Withdraw
  • Faucet
    • Faucet for Testnet Tokens
    • Claiming Testnet Tokens
  • Chain Snapshot
    • Download the Latest Chain Snapshot
  • Contract Address
    • Contract Address List
  • Bug Bounty
    • Bug Bounty Program
Powered by GitBook
On this page
  • STEP 1 - Get Started with Foundry
  • STEP 2 - Set Up Foundry Project
  • Step 3 - Example Contract: Counter.sol
  • Step 4 - Compiling the Contract
  • Step 5 - Deploying the Contract on Warehouse
  1. Deploy Contract

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.

When deploying a contract on any blockchain, the native token of that chain is required to pay gas fees. This applies to dKargo Chain as well. Before deploying on the dKargo testnet (Warehouse), developers can obtain $DKA testnet tokens via the faucet.

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 foundryup
  • Windows

curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs/> | sh cargo install --
git <https://github.com/foundry-rs/foundry> foundry-cli anvil --bins --locked

STEP 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.sol

Step 3 - Example Contract: Counter.sol

A 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 build

Step 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:Counter

Upon successful execution, the following response will be displayed:

The contract has been successfully deployed on dKargo’s Warehouse testnet.

PreviousDeploying a Contract Using HardhatNextERC-20 Bridging

Last updated 2 months ago

Copy the contract address specified in "Deployed to", and use it to search for deployment details on .

dScanner