Altnode is an ERC-721 NFT smart contract that enables creators to mint assets and manage subscription-based access to exclusive content. Built on Ethereum, it combines NFT ownership with a subscription model, allowing asset owners to monetize their content through time-based access controls.
- Contract Name: Altnode
- Symbol: AiT (Altnode Token)
- License: GPL-3.0
- Solidity Version: ^0.8.19
- Contract Address:
0xcb932746885aD1eB118a57E06dbB0cfa5f779E1c - Network: Ethereum Mainnet
- NFT Minting: Create unique asset tokens with metadata and subscription pricing
- Subscription System: Users can purchase time-based subscriptions to access exclusive content
- Access Control: Secure access to premium content using unique access keys
- Owner Payments: Subscription fees are automatically transferred to asset owners
- Subscription Management: Track active subscriptions and subscriber lists
- Asset Creation: Mint NFTs with public metadata and hidden asset URIs
- Subscription Purchasing: Buy access to assets for specified durations
- Access Key Generation: Unique keys for secure content access
- Subscription Validation: Check if subscriptions are active
- Subscriber Tracking: Monitor all subscribers for each asset
- Mints a new asset NFT
- Sets subscription price in wei
- Associates hidden content URI with the token
- Access: Public
- Purchase subscription to an asset
- Requires payment equal to or greater than subscription price
- Generates unique access key
- Access: Public (payable)
- Check if a subscription is currently active
- Returns boolean value
- Access: Public view
- Returns array of addresses with active subscriptions
- Access: External view
- Get public token metadata using access key
- Requires valid subscription
- Access: External view
- Get hidden asset content using access key
- Requires valid subscription
- Access: External view
- Retrieve access key for a specific asset and subscriber
- Access: External view
- Returns JSON string of all minted assets
- Access: External view
- Returns JSON string of all active subscriptions for an address
- Access: External view
struct Subscription {
uint256 validity; // Timestamp of subscription expiry
bytes32 accessKey; // Unique access key
}subscriptions: Maps token ID and subscriber to subscription detailssubscriptionPrices: Maps token ID to subscription priceaccessKeyToTokenId: Maps access key to corresponding token IDtokenIdToAssetURI: Maps token ID to hidden asset URIassetSubscribers: Tracks all subscribers for each asset
event TokenMinted(
address indexed to,
uint256 tokenId,
string tokenMetadata,
uint256 price
);event SubscriptionPurchased(
address indexed subscriber,
uint256 tokenId,
uint256 validity,
bytes32 accessKey,
uint256 price
);Altnode__InvalidAssetId: Asset ID doesn't existAltnode__SubscriptionExists: Active subscription already existsAltnode__InsufficientPayment: Payment below required amountAltnode__InvalidAccessKey: Access key is invalidAltnode__InvalidSubscription: Subscription is expired or invalidAltnode__OwnerCanNotPurchase: Asset owner cannot purchase their own subscriptionAltnode__OnlyOwner: Function restricted to contract owner
The contract includes owner-only functionality controlled by the onlyOwner modifier. Authorized addresses include:
- Contract deployer
0xe34b40f38217f9Dc8c3534735f7f41B2cDA73A750x6af90FF366aE23f4Bb719a56eBc910aF4C169aCE0xF23be0fbE9DEF26570278F91f3F150Af015a3ECf0xF5E93e4eEDbb1235B0FB200fd77068Cb9938eF4f
await altnodeContract.mintAsset(
"0x...", // recipient address
"ipfs://metadata-hash", // public metadata
"ipfs://secret-content-hash", // hidden content
ethers.utils.parseEther("0.1") // price in ETH
);await altnodeContract.purchaseSubscription(
0, // asset ID
86400, // duration in seconds (1 day)
{ value: ethers.utils.parseEther("0.1") }
);const accessKey = await altnodeContract.getAccessKeyByTokenId(0, userAddress);
const secretContent = await altnodeContract.getAssetURIByAccessKey(
accessKey,
userAddress
);- OpenZeppelin ERC721 implementation
- OpenZeppelin ERC721URIStorage extension
- OpenZeppelin Strings utility library
- Prevents asset owners from purchasing their own subscriptions
- Automatic payment forwarding to asset owners
- Unique access key generation using keccak256 hashing
- Subscription validity checks with timestamp-based expiration
- Comprehensive error handling with custom error types
# Compile with Hardhat
npx hardhat compile
# Or with Foundry
forge build# Run tests
npx hardhat test
# Or with Foundry
forge testThis project is licensed under the GPL-3.0 License - see the license identifier in the contract header.
For questions or support regarding the Altnode contract, please contact the Altnode development team.
Contract Address: 0xcb932746885aD1eB118a57E06dbB0cfa5f779E1c
Network: Ethereum Mainnet
