Getting Started
Getting Started Guide
JuChain currently supports Solidity versions <= 0.8.8 for compilation. Support for later versions will be rolled out based on official announcements.
Welcome to your JuChain developer journey! This guide will help you quickly get started with the JuChain platform—from setting up your development environment to deploying your first smart contract and connecting to the JuChain Testnet. Designed for developers new to JuChain, this section offers clear steps and practical examples to ensure you can start building right away.
Prerequisites
Before diving in, ensure you have the following knowledge and tools:
Basic Blockchain Knowledge: Familiarity with smart contracts, blockchain transactions, and the Ethereum Virtual Machine (EVM).
Development Tools:
Node.js (v16 or higher recommended): For running JavaScript and managing dependencies.
npm or yarn: Package managers for installing project dependencies.
Code Editor: Visual Studio Code or a similar tool is recommended.
Wallet: Install MetaMask or another EVM-compatible wallet to manage accounts and testnet tokens.
Terminal Skills: Basic command-line proficiency.
If you’re already familiar with Ethereum development, JuChain’s full EVM compatibility will make your transition seamless.
Step 1: Set Up Your Development Environment
Install Essential Tools
Install Node.js and npm
Download and install the latest Node.js version (includes npm) from nodejs.org.
Verify installation:
Optionally, install yarn:
npm install -g yarn
.
Install Truffle or Hardhat JuChain supports popular Ethereum frameworks. Here, we’ll use Hardhat:
Install Hardhat globally:
Create a new Hardhat project:
Select “Create a basic sample project” and follow the prompts to initialize.
Install MetaMask
Download and install the MetaMask browser extension from metamask.io.
Create or import a wallet account for testnet interactions.
Configure the JuChain Network
JuChain offers both mainnet and testnet environments. Below is the testnet configuration:
Network Name: JuChain Testnet
RPC URL:
https://testnet-rpc.juchain.org
Chain ID: 202599
Currency Symbol: JU
Block Explorer URL:
https://explorer-testnet.juchain.org
Add the JuChain Testnet to MetaMask:
Open MetaMask and click the “Network” dropdown.
Select “Add Network” > “Add a network manually”.
Enter the details above and save.
Step 2: Obtain Testnet JU Tokens
You’ll need JU tokens to deploy and test contracts on the JuChain Testnet. Get them via the official faucet:
Visit the JuChain Testnet Faucet: https://faucet-testnet.juchain.org.
Enter your MetaMask wallet address.
Click “Claim” to receive test JU (e.g., 10 JU daily).
Check your MetaMask balance on the JuChain Testnet to confirm.
Step 3: Write Your First Smart Contract
Here’s a simple contract example to store and retrieve data on JuChain.
Create the Smart Contract
In your Hardhat project, navigate to the
contracts
folder.Create a file named
SimpleStorage.sol
with this code:
Configure Hardhat
Open
hardhat.config.js
and add the JuChain Testnet configuration:Replace
YOUR_PRIVATE_KEY
with your MetaMask private key (exported from “Account Details”—never share publicly).
Install required Hardhat plugins:
Compile the Smart Contract
Compile the contract by running:
Upon success, compiled outputs will appear in the artifacts
folder.
Step 4: Deploy to JuChain Testnet
Write a Deployment Script
In the
scripts
folder, createdeploy.js
:Deploy the contract to the JuChain Testnet:
On success, the terminal will display the contract address, e.g.:
Verify deployment by entering the contract address into the JuChain Testnet Explorer:
https://explorer-testnet.juchain.org
.
Step 5: Interact with Your Smart Contract
Test Contract Functions
Open the Hardhat console:
Interact with the contract:
Expected output:
"42"
, confirming the contract works.
Frontend Interaction with ethers.js (Optional)
To interact via a webpage:
Initialize a frontend project:
Create
index.html
andapp.js
:
Step 6: Connect to JuChain Testnet Nodes
JuChain provides free public RPC nodes, so developers can build and test without running their own nodes.
Use Public RPC
Testnet RPC:
https://testnet-rpc.juchain.org
Use this URL directly in Hardhat or other tools to connect to the network.
Run Your Own Node
Not yet available.
Next Steps
Congratulations on deploying your first smart contract to the JuChain Testnet! Here’s what you can do next:
Explore the Developer Guide for deeper insights into APIs and traffic finance integration.
Check out Tutorials and Examples to build more complex dApps.
Join the JuChain developer community on Discord or Forums for support.
For issues, consult the FAQ or contact the technical support team.
Last updated