๐Ÿ“‹ 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 Name: NutriEmp-Chain
Chain ID: 432 (0x66950)
RPC URL: https://rpc.nutriemp-chain.link
Currency Symbol: GRAMZ
Block Explorer: https://explorer.nutriemp-chain.link

๐Ÿ“Š 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.

bash
# Initialize new project
npm init -y
npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers

# Initialize Hardhat
npx hardhat

Configure your hardhat.config.js:

javascript
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

bash
# Install Truffle
npm install -g truffle

# Initialize project
truffle init

Configure truffle-config.js:

javascript
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

bash
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Initialize project
forge init my-project

Configure foundry.toml:

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:

  1. Go to remix.ethereum.org
  2. Write your Solidity contract
  3. Compile the contract
  4. In the Deploy tab, select "Injected Provider - MetaMask"
  5. Make sure MetaMask is connected to NutriEmp-Chain
  6. 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:

solidity
// 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:

solidity
// 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

javascript
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);
}
javascript
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);
}
javascript
// 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

  • Web3.js - Ethereum JavaScript API
  • Ethers.js - Modern Web3 library
  • Wagmi - React hooks for Ethereum
  • Viem - TypeScript interface
๐Ÿ”

Testing & Analysis

๐Ÿ’ก Code Examples

๐Ÿš€

Deployment Script

Example Hardhat deployment script:

javascript
// 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:

bash
npx hardhat run scripts/deploy.js --network nutriemp
๐Ÿงช

Testing Example

javascript
// 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

  1. Fund your deployment wallet with GRAMZ
  2. Configure network settings
  3. Run deployment script
  4. Verify contract on explorer
  5. 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!

๐Ÿ”— Quick Links