Developer Quickstart
This guide walks from an empty directory to a deployed, verified contract on Xphere Testnet in about 10 minutes.
Prerequisites
- Node.js ≥ 18
- Wallet with XP testnet funds — get some at faucet.x-phere.com
- Basic Solidity knowledge
1. Scaffold a Hardhat Project
mkdir my-xphere-dapp && cd my-xphere-dapp
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
# Select: Create a TypeScript project
2. Configure Xphere Networks
Replace hardhat.config.ts:
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
const config: HardhatUserConfig = {
solidity: "0.8.24",
networks: {
xphereTestnet: {
url: "https://testnet.x-phere.com",
chainId: 1998991,
accounts: [process.env.PRIVATE_KEY!],
},
xphereMainnet: {
url: "https://en-hkg.x-phere.com",
chainId: 20250217,
accounts: [process.env.PRIVATE_KEY!],
},
},
};
export default config;
Export your private key (use a disposable dev wallet):
export PRIVATE_KEY=0xabc...
3. Write a Contract
contracts/Counter.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract Counter {
uint256 public count;
event Incremented(uint256 newValue);
function increment() external {
count += 1;
emit Incremented(count);
}
}
4. Deploy
scripts/deploy.ts:
import { ethers } from "hardhat";
async function main() {
const counter = await ethers.deployContract("Counter");
await counter.waitForDeployment();
console.log("Counter deployed to:", await counter.getAddress());
}
main().catch((e) => { console.error(e); process.exit(1); });
Run:
npx hardhat run scripts/deploy.ts --network xphereTestnet
# > Counter deployed to: 0xYour...Address
5. Interact
const counter = await ethers.getContractAt("Counter", "0xYourAddress");
const tx = await counter.increment();
await tx.wait();
console.log("count:", (await counter.count()).toString());
6. Verify Source on Explorer
npx hardhat verify --network xphereTestnet 0xYourAddress
Once verified, the source code and ABI become readable on xpt.tamsa.io.