Getting Started
Build Powerful dApps on Goliath Network
Welcome to the Goliath developer documentation! This guide will help you set up your development environment and start building decentralized applications on one of the fastest and most secure distributed ledger platforms.
π― Overview
Goliath provides developers with:
β‘ EVM Compatibility: Deploy existing Solidity contracts without modification
π High Performance: 100,000+ TPS with sub-second block confirmations and 3-5 second finality
π° Low Costs: Transaction fees under $0.001 USD
π§ Rich Tooling: Comprehensive SDKs and APIs
π Dual Layer Architecture: Access both EVM and native Core Ledger capabilities
β οΈ Critical: XCN Decimal Handling
Important difference from Ethereum: XCN uses 8 decimals inside the EVM (msg.value, address.balance) but 18 decimals in JSON-RPC responses. This is different from Ethereum where everything uses 18 decimals consistently.
Before you start coding, read the XCN Decimal Handling Guide to avoid critical bugs.
π οΈ Prerequisites
Before you begin, ensure you have:
Node.js (v16 or higher) - Download
Git - Download
Code Editor (VS Code recommended) - Download
MetaMask or similar Web3 wallet - Install
π Network Configuration
Testnet Details
const GOLIATH_TESTNET = {
name: 'Goliath Testnet',
chainId: 8901,
rpcUrl: 'https://rpc.testnet.goliath.net',
explorerUrl: 'https://testnet.explorer.goliath.net',
nativeCurrency: {
name: 'XCN',
symbol: 'XCN',
decimals: 18 // JSON-RPC uses 18 decimals (but EVM internally uses 8)
}
};API Endpoints
EVM RPC
https://rpc.testnet.goliath.net
Ethereum JSON-RPC compatible endpoint
Core Node
https://testnet.core.goliath.net
Native Goliath Core Node API
Indexer Node
https://testnet.indexer.goliath.net
Historical data and queries
WebSocket
wss://rpc.testnet.goliath.net/ws
Real-time event subscriptions
π Your First Smart Contract
1. Install Development Tools
# Install Hardhat (recommended framework)
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
# Or install Foundry for advanced users
curl -L https://foundry.paradigm.xyz | bash
foundryup2. Initialize Your Project
Using Hardhat:
mkdir my-goliath-dapp
cd my-goliath-dapp
npx hardhat initSelect "Create a JavaScript project" and follow the prompts.
3. Configure for Goliath
Update hardhat.config.js:
require("@nomicfoundation/hardhat-toolbox");
const PRIVATE_KEY = process.env.PRIVATE_KEY || "your-private-key-here";
module.exports = {
solidity: "0.8.19",
networks: {
goliathTestnet: {
url: "https://rpc.testnet.goliath.net",
chainId: 8901,
accounts: [PRIVATE_KEY],
gasPrice: 1000000000, // 1 Gwei
}
},
etherscan: {
apiKey: {
goliathTestnet: "not-required-for-testnet"
},
customChains: [
{
network: "goliathTestnet",
chainId: 8901,
urls: {
apiURL: "https://testnet.explorer.goliath.net/api",
browserURL: "https://testnet.explorer.goliath.net"
}
}
]
}
};4. Write Your Smart Contract
Create contracts/HelloGoliath.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract HelloGoliath {
string public greeting;
mapping(address => uint256) public greetingCounts;
event GreetingChanged(address indexed user, string newGreeting, uint256 count);
constructor(string memory _greeting) {
greeting = _greeting;
}
function setGreeting(string memory _newGreeting) public {
greeting = _newGreeting;
greetingCounts[msg.sender]++;
emit GreetingChanged(msg.sender, _newGreeting, greetingCounts[msg.sender]);
}
function getGreeting() public view returns (string memory) {
return greeting;
}
function getMyGreetingCount() public view returns (uint256) {
return greetingCounts[msg.sender];
}
}5. Deploy Your Contract
Create scripts/deploy.js:
const hre = require("hardhat");
async function main() {
console.log("Deploying to Goliath Testnet...");
const HelloGoliath = await hre.ethers.getContractFactory("HelloGoliath");
const hello = await HelloGoliath.deploy("Hello from Goliath!");
await hello.waitForDeployment();
const address = await hello.getAddress();
console.log("Contract deployed to:", address);
console.log("View on explorer:", `https://testnet.explorer.goliath.net/address/${address}`);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});Deploy:
npx hardhat run scripts/deploy.js --network goliathTestnetπ Interacting with Your Contract
Using Web3.js
const Web3 = require('web3');
const web3 = new Web3('https://rpc.testnet.goliath.net');
// Contract ABI (get from compilation)
const abi = [...];
const contractAddress = '0x...'; // Your deployed contract address
const contract = new web3.eth.Contract(abi, contractAddress);
// Read data
const greeting = await contract.methods.getGreeting().call();
console.log('Current greeting:', greeting);
// Write data (requires private key)
const account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
web3.eth.accounts.wallet.add(account);
const tx = await contract.methods.setGreeting('Hello Goliath!').send({
from: account.address,
gas: 100000,
gasPrice: web3.utils.toWei('1', 'gwei')
});
console.log('Transaction hash:', tx.transactionHash);Using Ethers.js
const { ethers } = require('ethers');
// Connect to Goliath
const provider = new ethers.JsonRpcProvider('https://rpc.testnet.goliath.net');
const signer = new ethers.Wallet(privateKey, provider);
// Connect to contract
const contract = new ethers.Contract(contractAddress, abi, signer);
// Read data
const greeting = await contract.getGreeting();
console.log('Current greeting:', greeting);
// Write data
const tx = await contract.setGreeting('Hello from Ethers!');
const receipt = await tx.wait();
console.log('Transaction confirmed in block:', receipt.blockNumber);β½ Gas Optimization
Goliath offers extremely low gas fees, but optimization is still important:
Gas Prices
Low
0.5 Gwei
Non-urgent transactions
Standard
1 Gwei
Regular transactions
Fast
2 Gwei
Priority transactions
Best Practices
Batch Operations: Combine multiple operations in a single transaction
Use Events: Emit events instead of storing data when possible
Optimize Storage: Pack structs and use appropriate data types
View Functions: Mark read-only functions as
vieworpure
π§ Development Tools
Essential Tools
Goliath-Specific Tools
Block Explorer:
https://testnet.explorer.goliath.netTest Tokens: Get test XCN via Telegram Community
Network Status: Real-time metrics and health
Faucet: Automated faucet coming soon
π― Advanced Features
1. Native Token Integration
Goliath supports native token creation without smart contracts:
// Using Core Ledger API
const response = await fetch('https://testnet.core.goliath.net/api/v1/tokens', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'My Token',
symbol: 'MTK',
decimals: 18,
initialSupply: '1000000',
treasury: accountId
})
});2. File Storage Service
Store files directly on the network:
// Store file on Goliath
const fileId = await goliathClient.createFile({
contents: Buffer.from('Hello World'),
memo: 'My first file on Goliath'
});3. Consensus Service (Goliath Mesh)
Achieve fair ordering for off-chain applications:
// Submit message to consensus
const message = {
threadId: 'my-app-thread',
data: { action: 'trade', amount: 100 },
timestamp: Date.now()
};
const consensusTimestamp = await goliathMesh.submitMessage(message);π Learning Resources
Tutorials
Code Examples
Simple dApp: Basic wallet interaction
NFT Marketplace: Full-stack NFT platform
DeFi Protocol: Lending and borrowing
DAO Governance: On-chain voting system
Documentation
π Common Issues & Solutions
Connection Issues
// Always use try-catch for RPC calls
try {
const balance = await provider.getBalance(address);
} catch (error) {
console.error('RPC Error:', error);
// Implement retry logic or fallback
}Gas Estimation
// Always estimate gas before sending
const estimatedGas = await contract.estimateGas.myMethod(params);
const tx = await contract.myMethod(params, {
gasLimit: estimatedGas * 110n / 100n // Add 10% buffer
});Transaction Monitoring
// Monitor transaction status
const receipt = await provider.waitForTransaction(txHash, 1, 30000);
if (receipt.status === 0) {
console.error('Transaction failed');
// Handle failure
}π What's Next?
Now that you have your development environment set up:
Deploy Smart Contracts - Deep dive into deployment
Hardhat Integration - Advanced Hardhat configuration
ERC Standards - Implement token standards
Gas Optimization - Minimize transaction costs
Security Best Practices - Build secure contracts
π€ Get Support
Telegram: Join our developer community
GitHub: Report issues and contribute
Community Forum: Technical discussions
Office Hours: Weekly developer calls
Ready to build? Start deploying your smart contracts on Goliath today!
Last updated