Builders Guide
Application Development
Smart Contracts
Solidity Guide

Building on GOAT Network

This guide provides comprehensive instructions for developing and deploying applications on GOAT Network using modern Ethereum development tools and practices.

Currently, GOAT Network is in testnet phase (Testnet3). This documentation reflects the latest testnet configuration and will be updated when mainnet launches.

Network Information

Testnet3 Configuration

ParameterValue
Network NameGOAT Testnet3
RPC URLhttps://rpc.testnet3.goat.network (opens in a new tab)
Chain ID48816
Currency SymbolBTC
Currency Decimal18
Block Explorerhttps://explorer.testnet3.goat.network (opens in a new tab)
Bridgehttps://bridge.testnet3.goat.network (opens in a new tab)
Faucethttps://bridge.testnet3.goat.network/faucet (opens in a new tab)

Development Setup

Prerequisites

  • Node.js (v16.0.0 or later)
  • Package manager (npm, yarn, or pnpm)
  • Git
  • Code editor (VS Code recommended)

Essential Tools

npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npm install --save-dev @openzeppelin/contracts
npm install --save ethers@^5.7.2 dotenv

Project Structure

my-goat-project/
├── contracts/
│   └── MyContract.sol
├── scripts/
│   ├── deploy.ts
│   └── interact.ts
├── test/
│   └── MyContract.test.ts
├── .env
├── hardhat.config.ts
├── package.json
└── README.md

Network Configuration

Hardhat Configuration

// hardhat.config.ts
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import * as dotenv from "dotenv";
 
dotenv.config();
 
const config: HardhatUserConfig = {
  solidity: "0.8.19",
  networks: {
    goatTestnet: {
      url: "https://rpc.testnet3.goat.network",
      chainId: 48816,
      accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
    },
    hardhat: {
      mining: {
        auto: true,
        interval: 5000
      }
    }
  },
  etherscan: {
    apiKey: {
      goatTestnet: process.env.EXPLORER_API_KEY || ""
    },
    customChains: [
      {
        network: "goatTestnet",
        chainId: 48816,
        urls: {
          apiURL: "https://explorer.testnet3.goat.network/api",
          browserURL: "https://explorer.testnet3.goat.network"
        }
      }
    ]
  }
};
 
export default config;

MetaMask Integration

export async function addGoatTestnetToMetaMask() {
  try {
    await window.ethereum.request({
      method: 'wallet_addEthereumChain',
      params: [{
        chainId: '0xBEA0', // 48816 in hex
        chainName: 'GOAT Testnet3',
        nativeCurrency: {
          name: 'Bitcoin',
          symbol: 'BTC',
          decimals: 18
        },
        rpcUrls: ['https://rpc.testnet3.goat.network'],
        blockExplorerUrls: ['https://explorer.testnet3.goat.network']
      }]
    });
  } catch (error) {
    console.error('Failed to add GOAT Testnet3:', error);
  }
}

Smart Contract Development

Basic Contract Example

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
 
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
 
contract GOATToken is ERC20, Ownable {
    constructor() ERC20("GOAT Token", "GOAT") {
        _mint(msg.sender, 1000000 * 10 ** decimals());
    }
 
    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

Deployment Script

// scripts/deploy.ts
import { ethers } from "hardhat";
 
async function main() {
  const GOATToken = await ethers.getContractFactory("GOATToken");
  const token = await GOATToken.deploy();
  await token.deployed();
 
  console.log(`GOATToken deployed to: ${token.address}`);
}
 
main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

Testing

Unit Tests

// test/GOATToken.test.ts
import { expect } from "chai";
import { ethers } from "hardhat";
import { GOATToken } from "../typechain-types";
 
describe("GOATToken", function () {
  let token: GOATToken;
 
  beforeEach(async function () {
    const GOATToken = await ethers.getContractFactory("GOATToken");
    token = await GOATToken.deploy();
    await token.deployed();
  });
 
  it("Should have correct initial supply", async function () {
    const totalSupply = await token.totalSupply();
    expect(totalSupply).to.equal(ethers.utils.parseEther("1000000"));
  });
});

Frontend Integration

ethers.js Setup

import { ethers } from 'ethers';
 
export function getGoatProvider() {
  // For browser environments
  if (window.ethereum) {
    return new ethers.providers.Web3Provider(window.ethereum);
  }
  
  // For backend or fallback
  return new ethers.providers.JsonRpcProvider(
    "https://rpc.testnet3.goat.network"
  );
}
 
export async function connectWallet() {
  const provider = getGoatProvider();
  await provider.send("eth_requestAccounts", []);
  return provider.getSigner();
}

Contract Interaction

import { ethers } from 'ethers';
import GOATTokenABI from './abis/GOATToken.json';
 
export class GOATTokenClient {
  private contract: ethers.Contract;
  private signer: ethers.Signer;
 
  constructor(
    contractAddress: string,
    signer: ethers.Signer
  ) {
    this.contract = new ethers.Contract(
      contractAddress,
      GOATTokenABI,
      signer
    );
    this.signer = signer;
  }
 
  async getBalance(address: string): Promise<string> {
    const balance = await this.contract.balanceOf(address);
    return ethers.utils.formatEther(balance);
  }
 
  async transfer(to: string, amount: string): Promise<ethers.ContractTransaction> {
    const parsedAmount = ethers.utils.parseEther(amount);
    return await this.contract.transfer(to, parsedAmount);
  }
}

Best Practices

⚠️

Following security best practices is crucial when developing on GOAT Network:

  • Always use the latest stable Solidity version
  • Implement proper access control
  • Use OpenZeppelin contracts whenever possible
  • Thoroughly test contracts before deployment
  • Consider gas optimization patterns
  • Get your contracts audited before mainnet deployment

Development Resources

Need testnet BTC? Visit the GOAT Testnet3 Faucet (opens in a new tab)

Support

For technical support and community discussions: