본문으로 건너뛰기

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)

  1. Open remix.ethereum.org
  2. Compile with Solidity ≥ 0.8.20
  3. Deploy & Run → Environment → Injected Provider - MetaMask
  4. Switch MetaMask to Xphere (see Wallet Setup)
  5. Click Deploy

Gas Pricing

FieldDefaultNotes
baseFeePerGasDynamic (EIP-1559)Adjusts every block based on network demand
minPriorityFeePerGas1 gweiTransactions below this are rejected
Block gas limit30,000,000Same 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.

See Also