### Start Vite Development Server Source: https://docs.soniclabs.com/sonic/build-on-sonic/native-usdc This command initiates the Vite development server, allowing you to run and test your React application locally. It's a crucial step after setting up the project and installing dependencies. ```bash npm run dev ``` -------------------------------- ### Start Sonic Node with Network Synchronization Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Starts the Sonic node with specified data directory, cache size, and external IP address for peer-to-peer connectivity. Adjust GOMEMLIMIT and cache based on available RAM. ```bash GOMEMLIMIT=50GiB sonicd --datadir --cache 12000 --nat extip: ``` -------------------------------- ### Clone Sonic Repository Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Downloads the Sonic source code from the official GitHub repository. This is the first step in building the Sonic client. ```git git clone https://github.com/0xsoniclabs/Sonic.git ``` -------------------------------- ### Start the Application using npm Source: https://docs.soniclabs.com/sonic/build-on-sonic/native-usdc This command initiates the development server for the React application. It allows for live reloading and serves the application locally. ```bash npm run dev ``` -------------------------------- ### Install Build Tools (Ubuntu/Debian) Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Installs essential build tools and Git on Ubuntu/Debian systems, which are necessary for compiling the Sonic node software. ```bash sudo apt-get update sudo apt-get install -y build-essential git ``` -------------------------------- ### Install Sonic Binaries Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Copies the compiled Sonic binaries to a system-wide accessible location, typically '/usr/local/bin', for easy execution. ```bash sudo cp build/sonic* /usr/local/bin/ ``` -------------------------------- ### Build Sonic Binary Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Compiles the Sonic project to create the necessary binaries for running a node. This command uses the 'make all' target. ```make make all ``` -------------------------------- ### Install Sonic Binaries Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Moves the compiled Sonic binaries to a system-wide location for easy access from any directory. ```bash sudo mv build/sonic* /usr/local/bin/ ``` -------------------------------- ### Download Sonic Mainnet Genesis File Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Downloads the genesis file for the Sonic mainnet, which is essential for initializing the node's state database. ```bash wget https://genesis.soniclabs.com/sonic-mainnet/genesis/sonic.g ``` -------------------------------- ### Install Go Compiler (Ubuntu/Debian) Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Installs the Go programming language compiler (version 1.23.4) on Ubuntu/Debian systems, a prerequisite for building the Sonic client. ```bash sudo rm -rf /usr/local/go wget https://go.dev/dl/go1.23.4.linux-amd64.tar.gz sudo tar -xzf go1.23.4.linux-amd64.tar.gz -C /usr/local/ rm -f go1.23.4.linux-amd64.tar.gz sudo tee /etc/profile.d/golang.sh > /dev/null < --cache 12000 genesis ``` -------------------------------- ### Prime Sonic State Database Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Initializes the Sonic state database using the downloaded genesis file with the 'sonictool'. Adjust GOMEMLIMIT and --cache based on available RAM. Recommended settings are 12GiB for --cache and ~90% of RAM for GOMEMLIMIT. ```bash GOMEMLIMIT=54GiB sonictool --datadir ~/.sonic \ --cache 12000 genesis \ --mode validator sonic.g ``` -------------------------------- ### Install Dependencies Source: https://docs.soniclabs.com/technology/pectra-compatibility/tic-tac-toe-demo Installs project dependencies for Node.js, Go, and the frontend application. Ensures all necessary libraries and packages are available. ```Bash # Install Node.js dependencies npm install # Install Go dependencies go mod download # Install frontend dependencies cd frontenddemo npm install cd .. ``` -------------------------------- ### Create and Initialize React Project with Vite Source: https://docs.soniclabs.com/sonic/build-on-sonic/native-usdc This snippet demonstrates the commands to create a new React project using Vite and initialize it with npm. It includes steps for creating the project directory, navigating into it, and initializing a new npm project. ```bash mkdir usdc-transfer-app cd usdc-transfer-app npminit-y ``` -------------------------------- ### Verify Sonic Node Version Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Executes the built Sonic daemon to display its version information, confirming a successful build. ```bash build/sonicd version ``` -------------------------------- ### Stop Sonic Node Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Gracefully stops the running Sonic node process using pkill. Avoid force-terminating to prevent database corruption. ```bash pkill sonicd ``` -------------------------------- ### Verify Sonic Genesis File Checksum Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Downloads the MD5 checksum file for the genesis file and verifies its integrity to ensure the downloaded file is not corrupted. ```bash wget https://genesis.soniclabs.com/sonic-mainnet/genesis/sonic.g.md5 md5sum --check sonic.g.md5 ``` -------------------------------- ### Sonic Gateway Setup (JavaScript) Source: https://docs.soniclabs.com/sonic/build-on-sonic/programmatic-gateway Demonstrates how to set up network RPC endpoints and initialize providers and signers for interacting with the Sonic Gateway. Requires Ethereum and Sonic RPC endpoints and a private key. ```JavaScript // Network RPC endpoints const ETHEREUM_RPC="https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"; const SONIC_RPC="https://rpc.soniclabs.com"; // Initialize providers const ethProvider=newethers.providers.JsonRpcProvider(ETHEREUM_RPC); const sonicProvider=newethers.providers.JsonRpcProvider(SONIC_RPC); // Initialize signer with your private key const PRIVATE_KEY="your-private-key"; constethSigner=newethers.Wallet(PRIVATE_KEY, ethProvider); constsonicSigner=newethers.Wallet(PRIVATE_KEY, sonicProvider); ``` -------------------------------- ### Run Sonic Validator Node Source: https://docs.soniclabs.com/sonic/node-deployment/validator-node This section outlines the essential steps to set up and run a validator node on the Sonic network. It covers server instance launch, tool installation, software build, database priming, network synchronization, wallet and key creation, validator registration, and node execution. ```bash # Example command for building the Sonic node software (hypothetical) # This would typically involve cloning a repository and running a build script. # git clone # cd sonic-node # make build ``` ```bash # Example command for priming the Sonic database (hypothetical) # This might involve initializing the database with genesis data. # sonic-node --init-db --genesis-file ``` ```bash # Example command for synchronizing with the network (hypothetical) # This would connect the node to the Sonic network and download the blockchain. # sonic-node --sync --network mainnet ``` ```bash # Example command for creating a validator wallet (hypothetical) # This would generate a new wallet address and private key. # sonic-cli wallet create --name myvalidator ``` ```bash # Example command for creating a validator signing key (hypothetical) # This key is used for signing blocks and transactions. # sonic-cli validator signkey create --wallet myvalidator ``` ```bash # Example command for registering your validator (hypothetical) # This submits your validator information to the network. # sonic-cli validator register --wallet myvalidator --signkey --stake 500000 ``` ```bash # Example command for running your validator node (hypothetical) # This starts the node and begins participating in consensus. # sonic-node --validator --wallet myvalidator --network mainnet --port 5050 ``` -------------------------------- ### Create Sonic Validator Signing Key Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Generates a signing key for your Sonic validator node, which is necessary for participating in consensus. Set a strong password and back up the key securely. ```bash sonictool --datadir ~/.sonic validator new ``` -------------------------------- ### Create Sonic Validator Wallet Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/validator-node Creates a new validator wallet using 'sonictool'. This wallet is used to identify and control your validator account. Securely store the generated keys. ```bash sonictool --datadir ~/.sonic account new ``` -------------------------------- ### Start the Application using npm Source: https://docs.soniclabs.com/~/changes/292/sonic/build-on-sonic/native-usdc This command initiates the development server for the React application. It allows you to run the USDC transfer sample app locally and access it via a specified URL. ```bash npm run dev ``` -------------------------------- ### Check Sonic Node Version Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/node-recovery This command allows you to check the currently installed version of the Sonic node software. It's often a prerequisite before performing recovery operations or upgrades to ensure compatibility. ```bash $ sonicd version Sonic Version: 2.0.5 Git Commit: ea9e363178ea9fb28a723beb803fb5dcf223cbbc ... ``` -------------------------------- ### Start Bundler Source: https://docs.soniclabs.com/technology/pectra-compatibility/tic-tac-toe-demo Starts the bundler service, which is responsible for aggregating UserOperations and submitting them to the EntryPoint contract. Requires cloning the bundler repository first. ```Bash # Clone the bundler (if not already done) git clone https://github.com/eth-infinitism/bundler cd bundler ``` -------------------------------- ### Enable Sonic Node HTTP Interface Source: https://docs.soniclabs.com/~/changes/292/sonic/node-deployment/archive-node Enables the HTTP interface for the Sonic node, allowing Web3 RPC communication. Configure the address, port, CORS, and enabled APIs according to your network requirements. ```bash --http --http.addr=0.0.0.0 --http.port=18545 --http.corsdomain=* --http.vhosts=* --http.api=eth,web3,net,ftm,txpool,abft,dag,trace,debug ``` -------------------------------- ### Check Sonic Node Version Source: https://docs.soniclabs.com/sonic/node-deployment/node-recovery This command allows you to check the currently installed version of the Sonic node software. It's a crucial step before performing recovery operations to ensure you are using the latest compatible version. ```Bash $ sonicd version Sonic Version: 2.0.5 Git Commit: ea9e363178ea9fb28a723beb803fb5dcf223cbbc ... ``` -------------------------------- ### Clone Repository Source: https://docs.soniclabs.com/technology/pectra-compatibility/tic-tac-toe-demo Clones the project repository and navigates into the project directory. This is the initial step for setting up the project locally. ```Bash git clone cd TicTacToeDemo ``` -------------------------------- ### Launch Frontend Demo Source: https://docs.soniclabs.com/technology/pectra-compatibility/tic-tac-toe-demo Command to start the frontend development server. Users should then open http://localhost:5173 in their browser. ```Shell cd frontenddemo npm run dev ```