Getting Started
This guide will help you set up and deploy ERC721S for your subscription-based service.
Prerequisites
- Foundry framework installed
- An Ethereum wallet with funds for deployment
- Basic familiarity with Solidity and smart contracts
Installation
Clone the repository and install dependencies:
git clone https://github.com/vorpalengineering/ERC721S.git
cd ERC721S
forge install
Build
Compile the smart contracts:
forge build
Testing
Run the test suite:
# Standard output
forge test
# Verbose output for debugging
forge test -vv
Deployment
Deploy the contract with your desired configuration. The constructor accepts the following parameters:
| Parameter | Type | Description |
|---|---|---|
name | string | Token collection name |
symbol | string | Token symbol |
owner | address | Contract owner address |
pricePerSecond | uint256 | Cost per second of subscription |
minDuration | uint256 | Minimum subscription duration in seconds |
maxDuration | uint256 | Maximum subscription duration in seconds |
fundsRecipient | address | Address to receive subscription payments |
Example Deployment
// Deploy with:
// - Name: "My Subscription"
// - Symbol: "MYSUB"
// - Owner: deployer address
// - Price: 0.0001 ETH per day (~1.157e-9 per second)
// - Min duration: 1 day (86400 seconds)
// - Max duration: 365 days (31536000 seconds)
// - Funds recipient: deployer address
ERC721S subscription = new ERC721S(
"My Subscription",
"MYSUB",
msg.sender,
1157407407407, // ~0.0001 ETH per day in wei per second
86400, // 1 day minimum
31536000, // 365 days maximum
msg.sender
);
Subscribing Users
Once deployed, users can subscribe by calling the subscribe() function with the appropriate payment:
// Get the cost for a 30-day subscription
uint256 cost = subscription.getSubscriptionCost(30 days);
// Subscribe (sends ETH with the transaction)
subscription.subscribe{value: cost}(30 days);
Next Steps
- Review the API Reference for all available functions
- Check the test files in the repository for more usage examples