Smart Contracts
Xphere is fully EVM-compatible at the Cancun upgrade level. Any contract that compiles for Ethereum mainnet runs on Xphere without modification.
Toolchains
Hardhat
Recommended for most TypeScript-based teams. See the Quickstart for a complete walkthrough.
Foundry
# foundry.toml
[rpc_endpoints]
xphere_mainnet = "https://en-hkg.x-phere.com"
xphere_testnet = "https://testnet.x-phere.com"
[etherscan]
xphere_testnet = { key = "verifyplaceholder", url = "https://xpt.tamsa.io/api" }
Deploy with:
forge create Counter --rpc-url xphere_testnet --private-key $PRIVATE_KEY
Remix (Browser)
- Open remix.ethereum.org
- Compile with Solidity ≥ 0.8.20
- Deploy & Run → Environment → Injected Provider - MetaMask
- Switch MetaMask to Xphere (see Wallet Setup)
- Click Deploy
Gas Pricing
| Field | Default | Notes |
|---|---|---|
baseFeePerGas | Dynamic (EIP-1559) | Adjusts every block based on network demand |
minPriorityFeePerGas | 1 gwei | Transactions below this are rejected |
| Block gas limit | 30,000,000 | Same as Ethereum mainnet |
Estimate gas before submitting:
const estimated = await contract.increment.estimateGas();
const tx = await contract.increment({ gasLimit: estimated * 12n / 10n }); // +20% buffer
Verifying Contracts
Tamsa Explorer supports Hardhat's verify plugin and Foundry's built-in forge verify-contract:
# Hardhat
npx hardhat verify --network xphereMainnet 0xContract "constructor" "args"
# Foundry
forge verify-contract 0xContract Counter --rpc-url xphere_mainnet \
--verifier blockscout \
--verifier-url https://xp.tamsa.io/api
Pre-deployed Standards
Battle-tested OpenZeppelin contracts are not auto-deployed — install via npm and inherit:
npm install @openzeppelin/contracts
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 1_000_000 * 10 ** decimals());
}
}
Common Patterns
Reading on-chain state from a backend
import { createPublicClient, http } from "viem";
import { xphere } from "./chains";
const client = createPublicClient({ chain: xphere, transport: http() });
const count = await client.readContract({
address: "0x...",
abi: counterAbi,
functionName: "count",
});
Subscribing to events (WebSocket)
import { createPublicClient, webSocket } from "viem";
const client = createPublicClient({
chain: xphere,
transport: webSocket("wss://en-hkg.x-phere.com/ws"),
});
client.watchContractEvent({
address: "0x...",
abi: counterAbi,
eventName: "Incremented",
onLogs: (logs) => console.log(logs),
});
Limitations
See EVM Compatibility for the full opcode and precompile matrix.