A React application for registering .vet.domains
names through the VeChain Name Service (VNS) partner registrar.
This application allows users to:
- Check availability of domain names
- View registration prices
- Register domain names with the VNS system
- Set reverse records for domain resolution
- React with TypeScript
- Vite for build tooling
- TanStack Query for data fetching
- VeChain DApp Kit for blockchain interaction
- Tailwind CSS for styling
The main hook that combines all VNS-related functionality. It manages the registration process and transaction status.
const {
checkAvailability, // Hook to check name availability
getPrice, // Hook to get registration price
register, // Function to register a name
error, // Current error state
transactionId, // Current transaction ID
transactionStatus, // Status of current transaction
resetTransaction // Reset transaction state
} = useVNS();
Checks if a domain name is available for registration.
const { data: isAvailable, isLoading } = useNameAvailability(name);
Features:
- Validates name format
- Checks availability on the VNS contract
- Returns boolean indicating availability
Retrieves the registration price for a domain name.
const { data: price, isLoading } = useNamePrice(name, duration);
Returns:
interface PriceResult {
base: string; // Base price in VET
premium: string; // Premium price in VET
rawBase: bigint; // Raw base price in Wei
rawPremium: bigint; // Raw premium price in Wei
total: string; // Total price in VET
}
Handles the domain registration process.
const { register } = useNameRegistration();
Registration process:
- Validates name format
- Creates registration transaction
- Sets up resolver
- Sets reverse record
- Handles transaction signing and submission
Names must meet the following criteria:
- Minimum 3 characters
- Cannot include the
.vet
suffix (added automatically) - Must use valid characters (normalized using ENS normalization)
The application interacts with the following VNS contracts:
- Partner Registrar:
0xa0b6d50571C81Bc46B9C1D5dB50f81533ac23AF5
- Public Resolver:
0xabac49445584C8b6c1472b030B1076Ac3901D7cf
- Reverse Registrar:
0x5c970901a587BA3932C835D4ae5FAE2BEa7e78Bc
-
Name Validation
- Check name length and format
- Normalize using ENS normalization
- Validate characters
-
Availability Check
- Query the VNS contract
- Verify name is available
-
Price Calculation
- Get base price
- Calculate premium (if any)
- Convert to user-friendly format
-
Registration
- Create registration transaction
- Set resolver
- Set reverse record
- Sign and submit transaction
-
Transaction Monitoring
- Track transaction status
- Update UI based on confirmation
- Handle errors
The application handles various error cases:
- Invalid name format
- Names that are too short
- Unavailable names
- Transaction failures
- Network errors
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview