XR One
  • Welcome
    • Introduction to XR One
      • Vision
      • About the XR One Network
        • Paint Points
        • The Future is DeMoN
          • DeMoN: A Decentralized Modular Network Whitepaper
    • Important Links
  • Technology
    • XR One
      • Architecture
        • Arbitrum Orbit
        • AnyTrust
          • Data Availability Committee (DAC)
        • RaaS
        • Accounts
          • Account Abstraction
          • Multi-Party Computation
        • Bridge
      • Partners
    • XR One Products
      • NFT Avatars
      • On-chain names
      • Marketplaces
      • On-chain tournaments
      • $XR1 liquidity mining
      • Faustian
    • Nodes
      • Hero Nodes
      • What are Hero Nodes?
      • What are Node Sales?
      • What Makes the Hero Node sale Different
      • Sale Structure
      • XR Airdrop for Node Holders
      • Daily rewards
    • Security
      • Audits
      • Bug Bounty
      • Sequencer Decentralization
      • Multi-Sig Operations
      • Withdrawal Delay
    • Roadmap
  • Tokenomics
    • $XR Token
      • Utility
      • Hero Node Pricing Tiers
    • Token Distribution
    • Emission Schedule
  • Ecosystem
    • Games
      • Saltwater Games
        • Celeros
        • Resurgence
        • Freerunner
    • Agentic AI
      • MySidekick
        • $SKICK
    • Native Tooling
      • Faustian
    • The XR Foundation
      • Constitution
      • ByLaws
      • Amended and Restated Articles of Association of the XR Foundation
      • Foundation Grants
      • DAO Governance
      • Stakeholders
  • Connect
    • XR Sepolia (Testnet)
      • tXR Token
      • Add XR Sepolia to Wallet
      • Bridge to XR Sepolia
      • XR Sepolia Block Explorer
      • XR Sepolia Analytics
    • XR One (Mainnet)
  • Deploy
    • Deploy to XR Sepolia
      • Using Foundry
      • Using Hardhat
      • Using Remix
  • GUIDES
    • Hero Nodes
      • Owner's Manual
        • Purchasing
        • Transferring
        • Delegation
      • Operator's Manual
        • Requirements
        • Installation
        • Operation
Powered by GitBook
On this page
  • What is Foundry?
  • Get Started with Foundry
  • Deploying Your Smart Contract
  1. Deploy
  2. Deploy to XR Sepolia

Using Foundry

What is Foundry?

Foundry is a toolset for Ethereum development written in Rust that assists developers in managing dependencies, compiling projects, running tests, deploying contracts, and interacting with blockchains through the command line interface.

Additionally, Foundry can directly communicate with Caldera's Ethereum API, enabling the use of Foundry to deploy smart contracts into the Caldera network.

Get Started with Foundry

  1. Install Foundry

    • Linux or MaxOS

      curl -L https://foundry.paradigm.xyz | bashfoundryup
    • 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
  2. Create a project

    forge init foundry
  3. Navigate to the Source in the project and create your smart contract

    cd src
    touch MyToken.sol
  4. Input your smart contract or use the sample contract below.

    // SPDX-License-Identifier: MIT
    
    
    // Compiler version must be greater than or equal to 0.8.17 and less than 0.9.0
    pragma solidity ^0.8.17;
    
    
    contract HelloWorld {
        string public greet = "Hello World!";
    }
  5. Install OpenZeppelin contracts as a dependency

    forge install OpenZeppelin/openzeppelin-contracts
  6. Compile contract

    forge build

Deploying Your Smart Contract

Deploying a contract with Forge is a simple process that can be done with a single command. However, it requires an RPC endpoint, a private key that has funds, and any arguments for the constructor of the contract.

For example, the MyToken.sol contract requires an initial supply of tokens to be specified in its constructor, so the command to deploy it on a network will include the argument of 100.

To deploy the MyToken.sol contract, use the command that corresponds to the Caldera chain's RPC URL while running the forge create command:

forge create --rpc-url "https://xr-sepolia-testnet.rpc.caldera.xyz/http"
--constructor-args 100 \
--private-key YOUR_PRIVATE_KEY \
src/MyToken.sol:MyToken 
PreviousDeploy to XR SepoliaNextUsing Hardhat

Last updated 1 year ago