๐ Developer Guide
๐ Quick Start
Get Started in 5 Minutes
NutriEmp-Chain is fully EVM-compatible, meaning you can use all your existing Ethereum development tools and knowledge. Here's what makes us special:
- Fast Transactions: ~3 second block times
- Low Costs: Gas fees under $0.01
- Ethereum Compatible: Use Solidity, Web3.js, Hardhat, etc.
- Proof of Authority: Environmentally friendly consensus
- Stable Network: Predictable performance
๐ก Perfect For
DeFi protocols, NFT marketplaces, gaming applications, IoT integrations, and any dApp requiring fast, cheap transactions.
โ๏ธ Network Configuration
Network Details
Use these configuration details to connect your applications to NutriEmp-Chain:
๐ Mainnet Configuration
๐ Network Stats
Block Time: ~3 seconds | Gas Price: 1 Gwei | Transaction Cost: ~$0.000005
๐ ๏ธ Development Setup
Hardhat Setup
Hardhat is the recommended development framework for NutriEmp-Chain.
# Initialize new project
npm init -y
npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers
# Initialize Hardhat
npx hardhat
Configure your hardhat.config.js
:
require("@nomiclabs/hardhat-ethers");
module.exports = {
solidity: "0.8.19",
networks: {
nutriemp: {
url: "https://rpc.nutriemp-chain.link",
chainId: 432,
accounts: [process.env.PRIVATE_KEY],
gasPrice: 1000000000, // 1 Gwei
}
},
etherscan: {
apiKey: {
nutriemp: "your-api-key" // For contract verification
},
customChains: [
{
network: "nutriemp",
chainId: 432,
urls: {
apiURL: "https://explorer.nutriemp-chain.link/api",
browserURL: "https://explorer.nutriemp-chain.link"
}
}
]
}
};
๐ก Environment Variables
Create a .env
file with your private key: PRIVATE_KEY=your_private_key_here
Truffle Setup
# Install Truffle
npm install -g truffle
# Initialize project
truffle init
Configure truffle-config.js
:
const HDWalletProvider = require('@truffle/hdwallet-provider');
module.exports = {
networks: {
nutriemp: {
provider: () => new HDWalletProvider(
process.env.MNEMONIC,
'https://rpc.nutriemp-chain.link'
),
network_id: 432,
gas: 4700000,
gasPrice: 1000000000,
}
},
compilers: {
solc: {
version: "0.8.19"
}
}
};
Foundry Setup
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup
# Initialize project
forge init my-project
Configure foundry.toml
:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc_version = "0.8.19"
[rpc_endpoints]
nutriemp = "https://rpc.nutriemp-chain.link"
[etherscan]
nutriemp = { key = "${ETHERSCAN_API_KEY}" }
Remix IDE
For quick prototyping and testing, use Remix IDE:
- Go to remix.ethereum.org
- Write your Solidity contract
- Compile the contract
- In the Deploy tab, select "Injected Provider - MetaMask"
- Make sure MetaMask is connected to NutriEmp-Chain
- Deploy your contract
โ Quick Testing
Remix is perfect for rapid prototyping and testing small contracts before moving to a full development environment.
๐ Smart Contracts
Basic Contract
Simple storage contract example:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract SimpleStorage {
uint256 private storedData;
address public owner;
event DataStored(uint256 data, address indexed by);
constructor() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
function set(uint256 x) public onlyOwner {
storedData = x;
emit DataStored(x, msg.sender);
}
function get() public view returns (uint256) {
return storedData;
}
}
ERC-20 Token
Standard ERC-20 token implementation:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyToken is ERC20, Ownable {
constructor(
string memory name,
string memory symbol,
uint256 initialSupply
) ERC20(name, symbol) {
_mint(msg.sender, initialSupply * 10**decimals());
}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
โ ๏ธ Gas Optimization
While gas costs are low on NutriEmp-Chain, it's still good practice to optimize your contracts. Use view functions when possible and minimize storage operations.
๐ Web3 Integration
import Web3 from 'web3';
// Connect to NutriEmp-Chain
const web3 = new Web3('https://rpc.nutriemp-chain.link');
// Check connection
async function checkConnection() {
try {
const blockNumber = await web3.eth.getBlockNumber();
console.log('Connected! Latest block:', blockNumber);
return true;
} catch (error) {
console.error('Connection failed:', error);
return false;
}
}
// Connect wallet
async function connectWallet() {
if (window.ethereum) {
try {
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x66950',
chainName: 'NutriEmp-Chain',
nativeCurrency: {
name: 'GRAMZ',
symbol: 'GRAMZ',
decimals: 18
},
rpcUrls: ['https://rpc.nutriemp-chain.link'],
blockExplorerUrls: ['https://explorer.nutriemp-chain.link']
}]
});
const accounts = await window.ethereum.request({
method: 'eth_requestAccounts'
});
return accounts[0];
} catch (error) {
console.error('Failed to connect:', error);
}
}
}
// Interact with contract
const contractABI = [/* Your contract ABI */];
const contractAddress = '0x...';
const contract = new web3.eth.Contract(contractABI, contractAddress);
// Call contract method
async function callContract() {
const result = await contract.methods.get().call();
console.log('Contract result:', result);
}
import { ethers } from 'ethers';
// Connect to NutriEmp-Chain
const provider = new ethers.JsonRpcProvider('https://rpc.nutriemp-chain.link');
// Check connection
async function checkConnection() {
try {
const network = await provider.getNetwork();
console.log('Connected to:', network.name, 'Chain ID:', network.chainId);
return true;
} catch (error) {
console.error('Connection failed:', error);
return false;
}
}
// Connect wallet
async function connectWallet() {
if (window.ethereum) {
const provider = new ethers.BrowserProvider(window.ethereum);
try {
await provider.send("wallet_addEthereumChain", [{
chainId: "0x66950",
chainName: "NutriEmp-Chain",
nativeCurrency: {
name: "GRAMZ",
symbol: "GRAMZ",
decimals: 18
},
rpcUrls: ["https://rpc.nutriemp-chain.link"],
blockExplorerUrls: ["https://explorer.nutriemp-chain.link"]
}]);
const signer = await provider.getSigner();
const address = await signer.getAddress();
console.log('Connected:', address);
return signer;
} catch (error) {
console.error('Failed to connect:', error);
}
}
}
// Interact with contract
const contractABI = [/* Your contract ABI */];
const contractAddress = '0x...';
async function interactWithContract() {
const signer = await connectWallet();
const contract = new ethers.Contract(contractAddress, contractABI, signer);
// Read from contract
const value = await contract.get();
console.log('Current value:', value);
// Write to contract
const tx = await contract.set(42);
await tx.wait();
console.log('Transaction confirmed:', tx.hash);
}
// React component example
import { useAccount, useConnect, useDisconnect } from 'wagmi';
function WalletConnection() {
const { address, isConnected } = useAccount();
const { connect, connectors } = useConnect();
const { disconnect } = useDisconnect();
if (isConnected) {
return (
<div>
<p>Connected: {address}</p>
<button onClick={() => disconnect()}>Disconnect</button>
</div>
);
}
return (
<div>
{connectors.map((connector) => (
<button
key={connector.id}
onClick={() => connect({ connector })}
>
Connect {connector.name}
</button>
))}
</div>
);
}
๐ง Tools & Libraries
Development
Web3 Libraries
Testing & Analysis
- OpenZeppelin - Secure contracts
- MythX - Security analysis
- Slither - Static analysis
- Tenderly - Debugging platform
๐ก Code Examples
Deployment Script
Example Hardhat deployment script:
// scripts/deploy.js
const { ethers } = require("hardhat");
async function main() {
console.log("Deploying to NutriEmp-Chain...");
// Get the contract factory
const SimpleStorage = await ethers.getContractFactory("SimpleStorage");
// Deploy the contract
const simpleStorage = await SimpleStorage.deploy();
await simpleStorage.waitForDeployment();
const address = await simpleStorage.getAddress();
console.log("SimpleStorage deployed to:", address);
// Verify the contract (optional)
if (network.name !== "hardhat") {
console.log("Waiting for block confirmations...");
await simpleStorage.deploymentTransaction().wait(6);
await hre.run("verify:verify", {
address: address,
constructorArguments: [],
});
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Deploy with:
npx hardhat run scripts/deploy.js --network nutriemp
Testing Example
// test/SimpleStorage.test.js
const { expect } = require("chai");
const { ethers } = require("hardhat");
describe("SimpleStorage", function () {
let simpleStorage;
let owner;
let addr1;
beforeEach(async function () {
[owner, addr1] = await ethers.getSigners();
const SimpleStorage = await ethers.getContractFactory("SimpleStorage");
simpleStorage = await SimpleStorage.deploy();
await simpleStorage.waitForDeployment();
});
describe("Deployment", function () {
it("Should set the right owner", async function () {
expect(await simpleStorage.owner()).to.equal(owner.address);
});
it("Should initialize with zero value", async function () {
expect(await simpleStorage.get()).to.equal(0);
});
});
describe("Storage", function () {
it("Should store the value", async function () {
await simpleStorage.set(42);
expect(await simpleStorage.get()).to.equal(42);
});
it("Should emit DataStored event", async function () {
await expect(simpleStorage.set(42))
.to.emit(simpleStorage, "DataStored")
.withArgs(42, owner.address);
});
it("Should revert if not owner", async function () {
await expect(simpleStorage.connect(addr1).set(42))
.to.be.revertedWith("Not owner");
});
});
});
๐ Deployment
Deployment Checklist
โ Pre-Deployment
- Test contracts thoroughly on local network
- Audit smart contracts for security vulnerabilities
- Optimize gas usage
- Prepare deployment scripts
- Set up environment variables
๐ Deployment Steps
- Fund your deployment wallet with GRAMZ
- Configure network settings
- Run deployment script
- Verify contract on explorer
- Test deployed contract functionality
๐ Post-Deployment
- Monitor contract performance
- Set up event monitoring
- Document contract addresses
- Update frontend configurations
๐ฐ Deployment Costs
Typical deployment costs on NutriEmp-Chain are under $0.01, making it extremely affordable to deploy and test contracts.
โ Best Practices
Security
- Use OpenZeppelin contracts when possible
- Implement proper access controls
- Validate all inputs
- Use reentrancy guards
- Audit contracts before mainnet deployment
- Keep private keys secure
- Use multi-signature wallets for important contracts
Performance
- Minimize storage operations
- Use events for logging
- Batch operations when possible
- Use view functions for read operations
- Optimize contract size
- Cache frequently used values
- Consider gas costs in design
๐ก Development Tips
Start with simple contracts and gradually add complexity. Use version control, write comprehensive tests, and document your code thoroughly. The NutriEmp-Chain community is here to help!