ShapeXp is a Cross-World NFT Experience System for ShapeCraft. The goal of ShapeXp is to provide a utility tool for game developers which makes it easy to delegate some complexity of their world design, by providing a standalone security, experience, and inventory management system.
- Soulbound ShapeXp NFT
- One-per-address access token
- Non-transferable (soulbound) implementation
- Required for system interaction
- Secure access control mechanism
- Dual Experience Tracking
- Global experience pool for users
- NFT-specific experience tracking
- Experience transfer mechanism between global and NFT pools
- Maximum cap of 100,000 experience points
- Tiered Experience Gains
- LOW: 1,000 points
- MID: 2,500 points
- HIGH: 5,000 points
- Anti-Spam Protection
- 30-minute cooldown between experience gains
- Experience transfer rate of 500 points
- NFT Inventory System
- Fixed 3-slot inventory per user
- Support for any ERC721 NFT
- NFT experience tracking
- Add/remove NFT capabilities
- Built-in Validations
- NFT ownership verification
- Inventory slot availability checks
- Experience balance validation
- Cooldown period enforcement
- Comprehensive API
- Global JavaScript API
- Event tracking and notifications
- Experience management functions
- Inventory manipulation methods
git clone https://github.com/ATrnd/ShapeXp.git
cd ShapeXp
If you don't have Foundry installed, run:
curl -L https://foundry.paradigm.xyz | bash
foundryup
Install Foundry dependencies
# cd ShapeXp
foundry install
forge test
cd frontend
npm install
npm run dev
Create a .env
file in the frontend
directory with the following variables:
# For Shape Sepolia
VITE_ALCHEMY_API_KEY=your_api_key
VITE_SEPOLIA_RPC_URL=https://shape-sepolia.g.alchemy.com/v2/your_api_key
VITE_SEPOLIA_BASE_URL=https://shape-sepolia.g.alchemy.com/v2
# For Shape Mainnet (overwrite Sepolia variables)
# VITE_ALCHEMY_API_KEY=your_api_key
# VITE_SEPOLIA_RPC_URL=https://shape-mainnet.g.alchemy.com/v2/your_api_key
# VITE_SEPOLIA_BASE_URL=https://shape-mainnet.g.alchemy.com/v2/
- Node.js with npm
- Vite 6.0.1
- TypeScript 5.6.2
- Ethers.js 6.13.4
- TailwindCSS 3.4.16
- PostCSS 8.4.49
- Autoprefixer 10.4.20
- Foundry 0.2.0
https://github.com/ATrnd/ShapeXpSandbox
Core implementation of ShapeXp UI functionalities and API. This repository contains the implementation of the window.ShapeXpAPI
interface and core functionality.
https://github.com/ATrnd/ShapeXpFrontEnd
Prototype frontend implementation demonstrating ShapeXp integration and usage. Used for initial prototyping and testing of the ShapeXp system.
ShapeXpNFT => 0x2a12F0d3aa55656642BeD81337957e610E450607
ShapeXpInvExp => 0x821098072DFB484e54218500F98C37f824bbb325
ShapeXpNFT => 0x2a12F0d3aa55656642BeD81337957e610E450607
ShapeXpInvExp => 0x821098072DFB484e54218500F98C37f824bbb325
ShapeXp provides a global JavaScript API (window.ShapeXpAPI
) for integrating ShapeXp functionality into web applications. The API enables experience tracking, NFT management, and inventory operations.
// Check if user has ShapeXp NFT
const hasNFT = await window.ShapeXpAPI.hasShapeXp();
console.log('Has ShapeXp NFT:', hasNFT);
Get current account's ShapeXp amount.
const xp = await ShapeXpAPI.getShapeXp();
Add global experience points. Type can be "LOW", "MID", or "HIGH".
const result = await ShapeXpAPI.addGlobalExperience("LOW");
if (result.success) {
console.log('Transaction:', result.transactionHash);
}
Mint a new ShapeXp NFT.
const result = await ShapeXpAPI.mintShapeXp();
if (result.success) {
console.log('Minting successful:', result.tx);
}
Get all NFTs for current address or specified address.
const {success, nfts} = await ShapeXpAPI.getNFTs();
if (success) {
console.log('NFTs:', nfts);
}
Get inventory for current address or specified address.
const {success, inventory} = await ShapeXpAPI.getInventory();
Add NFT to ShapeXp inventory.
const result = await ShapeXpAPI.addNFTToInventory(
"0x123...",
"1"
);
Remove NFT from ShapeXp inventory.
const result = await ShapeXpAPI.removeNFTFromInventory(
"0x123...",
"1"
);
Get experience points for a specific NFT.
const {success, experience} = await ShapeXpAPI.getNFTExperience(
"0x123...",
"1"
);
Add experience points to a specific NFT.
const result = await ShapeXpAPI.addNFTExperience(
"0x123...",
"1"
);
Look up ShapeXp amount for any address.
const result = await ShapeXpAPI.shapeXpLookup("0x123...");
if (result.success) {
console.log('Amount:', result.amount);
console.log('Raw:', result.raw);
}
Check if an address owns ShapeXp NFT.
const result = await ShapeXpAPI.shapeXpLookupNFT("0x123...");
if (result.success) {
console.log('Has NFT:', result.hasNFT);
}
All methods return a standardized response object:
{
success: true;
// Additional data specific to the method
} | {
success: false;
error: string;
}
Here's a step-by-step guide to test the complete functionality of ShapeXp.
-
Connect the ShapeXp Dapp
- UI: Click the "Connect" button
- API: No API call needed - wallet connection handled by UI
-
Mint a ShapeXp Token
- UI: Click the "Mint ShapeXp" button
- API:
// Mint a ShapeXp NFT await ShapeXpAPI.mintShapeXp()
-
Gain ShapeXp
- UI: Use the "Gain Shapexp" buttons in the experience section, (note: adding experience has a 30 minute cooldown / address)
- API:
// Add global experience points (LOW/MID/HIGH) await ShapeXpAPI.addGlobalExperience("HIGH")
-
Lookup your NFTs
// Get all NFTs for current address
await ShapeXpAPI.getNFTs()
- Get current account's inventory
// Fetch inventory
await ShapeXpAPI.getInventory()
- Add NFT to inventory
// Add NFT using contract address and token ID
await ShapeXpAPI.addNFTToInventory(contract, tokenId)
- Verify if NFT is added
// Check updated inventory
await ShapeXpAPI.getInventory()
- Add experience to NFT
// Add experience to specific NFT
await ShapeXpAPI.addNFTExperience(contract, tokenId)
- Verify if experience is added
// Check NFT experience
await ShapeXpAPI.getNFTExperience(contract, tokenId)
- Remove NFT from inventory
// Remove NFT from ShapeXp inventory
await ShapeXpAPI.removeNFTFromInventory(contractAddress, tokenId)
- Verify if NFT is removed
// Check updated inventory
await ShapeXpAPI.getInventory()
- Dan Nolan, for providing awesome resources, tips and tricks, and support when I was struggling with ShapeXp
- Alex, for giving feedback and helping me brainstorm about how I could improve ShapeXp
- Han, for being gentle and kind and making ShapeCraft possible for all of us
- All the participants, taking part in this journey with me and shaping the foundations of a radical new world