Skip to content

Sandbox Passes contract #1619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
67bf952
Add package for passes contract with initial contract code
wojciech-turek Jan 7, 2025
aad7f40
implement new features
wojciech-turek Feb 4, 2025
ebe1b88
Merge branch 'master' of github.com-personal:thesandboxgame/sandbox-s…
wojciech-turek Feb 15, 2025
4d381e7
Update passes contract
wojciech-turek Feb 25, 2025
4d6c7b3
Fix stack too deep error
wojciech-turek Feb 25, 2025
9f2b015
Add tests
wojciech-turek Mar 4, 2025
4d76694
lint fix
wojciech-turek Mar 4, 2025
04870c1
Add more test cases
wojciech-turek Mar 4, 2025
bc024cd
Lint fix
wojciech-turek Mar 4, 2025
9e10799
Further lint fix and readme update
wojciech-turek Mar 4, 2025
9ac6f8a
readme update
wojciech-turek Mar 4, 2025
2b899af
Remove empty contract file
wojciech-turek Mar 6, 2025
50a6d82
Pass signature check error to custom error
wojciech-turek Mar 6, 2025
ac6375d
Re-use mint process code instead of duplicating
wojciech-turek Mar 6, 2025
dcfe8b8
Add caller to admin events and emit one event for whitelist update in…
wojciech-turek Mar 6, 2025
e0af8e6
Improve the _update function to save gas
wojciech-turek Mar 6, 2025
4315ce1
Use fixtures, use ERC7201 spec, batch mint limit
wojciech-turek Mar 7, 2025
fe36775
Update the user mint functions to work with approveAndCall
wojciech-turek Mar 7, 2025
eceeab0
lint fix
wojciech-turek Mar 7, 2025
841b261
Non admin tests
wojciech-turek Mar 7, 2025
3baa039
Non admin mint tests
wojciech-turek Mar 7, 2025
156c1ff
Add nonce tests
wojciech-turek Mar 7, 2025
4841da1
Add operator role checks
wojciech-turek Mar 7, 2025
4d36bc4
Rename test title
wojciech-turek Mar 7, 2025
e515992
Additional bad signature tests
wojciech-turek Mar 7, 2025
657e025
Add a getter override for exists check
wojciech-turek Mar 7, 2025
63bc2b8
lint fix
wojciech-turek Mar 7, 2025
2f35411
Remove unused error and move it down in the contract
wojciech-turek Mar 7, 2025
9aff36a
Update initialize fn natspec
wojciech-turek Mar 7, 2025
502d247
isTransferWhitelisted change from public to external
wojciech-turek Mar 7, 2025
00bcd26
lint fix
wojciech-turek Mar 7, 2025
1da60d0
update strorage var visibility
wojciech-turek Mar 7, 2025
fa2db82
Update lint
wojciech-turek Mar 7, 2025
36b10b9
Reorder functions within contract
wojciech-turek Mar 10, 2025
81b08de
max-supply-check
wojciech-turek Mar 24, 2025
9d8600f
Add the missing mintedPerWallet updates, allow for unlimited per wall…
wojciech-turek Mar 24, 2025
67ace29
include total minted amount in the getter
wojciech-turek Mar 24, 2025
579000b
Merge branch 'passes-audit-h-01' of github.com-personal:thesandboxgam…
wojciech-turek Mar 24, 2025
fff6f13
Add maxPerWallet check to operator functions
wojciech-turek Mar 24, 2025
0cd4f0c
Add missing test
wojciech-turek Mar 24, 2025
f8ca5a3
Update batch mint function to accept single signature
wojciech-turek Mar 24, 2025
f0caa77
Only emit events when values change
wojciech-turek Mar 24, 2025
89f4a77
Remove floating pragma
wojciech-turek Mar 24, 2025
a1b423d
Reorganize TokenConfig struct data order
wojciech-turek Mar 24, 2025
9355d7f
Adde event coumentation
wojciech-turek Mar 24, 2025
06689e3
Add event for owner change
wojciech-turek Mar 24, 2025
5d279f1
Adhere to EIP-7201
wojciech-turek Mar 24, 2025
01d99a0
Use calldata instead of memory
wojciech-turek Mar 24, 2025
e9ad2c6
Rename the contract
wojciech-turek Mar 24, 2025
31e52d1
Fix function and layout order
wojciech-turek Mar 24, 2025
a64d3eb
Added named parameters in mappings
wojciech-turek Mar 24, 2025
d271d03
Add security contact
wojciech-turek Mar 24, 2025
a81765f
Limit function visibility
wojciech-turek Mar 24, 2025
47b5baf
Remove named return
wojciech-turek Mar 24, 2025
b9a4f9b
Update tests
wojciech-turek Mar 24, 2025
304b2ce
Use signature id instead of sequential nonce
wojciech-turek Mar 25, 2025
164d80a
Use max uint for unlimited editions
wojciech-turek Mar 25, 2025
5645525
Removed unnecessary comments
wojciech-turek Mar 25, 2025
0cf0231
Do a check for the caller for user functions
wojciech-turek Mar 26, 2025
5a61f9d
Disallow same id for burn and mint and setting passes contract as tre…
wojciech-turek Mar 26, 2025
91500df
lint fix
wojciech-turek Mar 26, 2025
8a46f4d
Allow same token burn and mint
wojciech-turek Mar 27, 2025
c2b8e88
Update the comment to prevent confusion
wojciech-turek Mar 27, 2025
b250767
Pre-calculate the storage slots
wojciech-turek Apr 2, 2025
b5bb745
Fix function ordering
wojciech-turek Apr 2, 2025
7c60782
Update naming of the variable and function
wojciech-turek Apr 2, 2025
190726b
Update tests
wojciech-turek Apr 3, 2025
c922808
Update the comments
wojciech-turek Apr 3, 2025
eec49f6
Mark the signature verification functions internal
wojciech-turek Apr 8, 2025
a4d8f9f
Remove redundant check
wojciech-turek Apr 8, 2025
2e3b907
Merge pull request #1682 from thesandboxgame/passes-audit-n-09
wojciech-turek Apr 15, 2025
5dfaeac
Merge pull request #1681 from thesandboxgame/passes-audit-h-02
wojciech-turek Apr 15, 2025
2e3a581
Merge pull request #1678 from thesandboxgame/passes-audit-h-01-follow-up
wojciech-turek Apr 15, 2025
ac03964
Merge pull request #1677 from thesandboxgame/passes-audit-n-04-follow-up
wojciech-turek Apr 15, 2025
e0bc18f
Merge pull request #1676 from thesandboxgame/passes-audit-n-01-follow-up
wojciech-turek Apr 15, 2025
7303c48
Merge pull request #1674 from thesandboxgame/passes-audit-l-07
wojciech-turek Apr 15, 2025
cbe7e70
Merge pull request #1673 from thesandboxgame/no-caller-check
wojciech-turek Apr 15, 2025
67a4af4
Merge pull request #1672 from thesandboxgame/use-max-for-unlimited
wojciech-turek Apr 15, 2025
6701902
Merge pull request #1671 from thesandboxgame/change-nonces-to-signatu…
wojciech-turek Apr 15, 2025
dfa768d
Merge pull request #1670 from thesandboxgame/passes-audit-n-08
wojciech-turek Apr 15, 2025
d2cd760
Merge pull request #1669 from thesandboxgame/passes-audit-n-07
wojciech-turek Apr 15, 2025
7cbe142
Merge pull request #1668 from thesandboxgame/passes-audit-n-06
wojciech-turek Apr 15, 2025
11fb6f8
Merge pull request #1667 from thesandboxgame/passes-audit-n-05
wojciech-turek Apr 15, 2025
eec5487
Merge pull request #1666 from thesandboxgame/passes-audit-n-04
wojciech-turek Apr 15, 2025
d5af5d6
Merge pull request #1665 from thesandboxgame/passes-audit-n-03
wojciech-turek Apr 15, 2025
e93c9b3
Merge pull request #1664 from thesandboxgame/passes-audit-n-02
wojciech-turek Apr 15, 2025
d5f392b
Merge pull request #1663 from thesandboxgame/passes-audit-n-01
wojciech-turek Apr 15, 2025
2563520
Merge pull request #1662 from thesandboxgame/passes-audit-l-05
wojciech-turek Apr 15, 2025
95e94ba
Merge pull request #1661 from thesandboxgame/passes-audit-l-04
wojciech-turek Apr 15, 2025
179f24e
Merge pull request #1660 from thesandboxgame/passes-audit-l-03
wojciech-turek Apr 15, 2025
e3e8211
Merge pull request #1659 from thesandboxgame/passes-audit-l-02
wojciech-turek Apr 15, 2025
629e449
Merge pull request #1658 from thesandboxgame/passes-audit-l-01
wojciech-turek Apr 15, 2025
5d34ed1
Merge pull request #1657 from thesandboxgame/passes-audit-m-04
wojciech-turek Apr 15, 2025
32ba9c1
Merge pull request #1656 from thesandboxgame/passes-audit-m-03
wojciech-turek Apr 15, 2025
235e241
Merge pull request #1655 from thesandboxgame/passes-audit-m-02
wojciech-turek Apr 15, 2025
05a243f
Merge pull request #1654 from thesandboxgame/passes-audit-h-01
wojciech-turek Apr 15, 2025
04e213f
Merge branch 'master' of github.com-personal:thesandboxgame/sandbox-s…
wojciech-turek Apr 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/game-passes/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# generated docs
generated-markups

# editors
.idea
41 changes: 41 additions & 0 deletions packages/game-passes/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const path = require('path');
const tsconfigPath = path.join(__dirname, 'tsconfig.json');
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:mocha/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaVersion: 2020,
},
plugins: ['mocha'],
env: {
commonjs: true,
node: true,
mocha: true,
},
overrides: [
{
files: ['*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [tsconfigPath],
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: ['mocha', '@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:mocha/recommended',
'plugin:prettier/recommended',
],
rules: {
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-floating-promises': 'error',
},
},
],
};
17 changes: 17 additions & 0 deletions packages/game-passes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts
./artifacts
./cache
./typechain

deployments

storageLayout
16 changes: 16 additions & 0 deletions packages/game-passes/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# generated docs
generated-markups

# editors
.idea
21 changes: 21 additions & 0 deletions packages/game-passes/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
singleQuote: true,
bracketSpacing: false,
plugins: ['prettier-plugin-solidity'],
overrides: [
{
files: '*.md',
options: {
proseWrap: 'always',
},
},
{
files: '*.sol',
options: {
printWidth: 120,
tabWidth: 4,
singleQuote: false,
},
},
],
};
7 changes: 7 additions & 0 deletions packages/game-passes/.solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
mocha: {
grep: '@skip-on-coverage', // Find everything with this tag
invert: true, // Run the grep's inverse set.
},
skipFiles: ['mock'],
};
14 changes: 14 additions & 0 deletions packages/game-passes/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
}
],
"compiler-version": ["error", "^0.8.0"],
"func-visibility": ["error", {"ignoreConstructors": true}]
}
}
86 changes: 86 additions & 0 deletions packages/game-passes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SandboxPasses1155 - NFT Pass System

## Overview

SandboxPasses1155 is a smart contract that powers a flexible NFT pass system on
the Ethereum blockchain. It allows for the creation, management, and
distribution of digital passes that can be used for various purposes including
event access, membership benefits, and digital collectibles.

## Key Features

### 📱 Multi-Token Support

- A single contract can manage many different types of passes
- Each pass type has its own configuration, supply limits, and transferability
rules

### 🔒 Flexible Transferability

- Passes can be configured as transferable or non-transferable (soulbound)
- Admins can whitelist specific addresses to transfer otherwise non-transferable
passes
- Helps maintain integrity for access passes and credentials

### 🏷️ Supply Controls

- Set maximum supply limits for each pass type
- Configure how many of each pass type a single wallet can hold
- Prevent overconcentration of passes in single wallets

### 💰 Payment Integration

- Built-in support for payments in ERC20 tokens
- Configurable treasury addresses to receive payments
- Different pass types can have different payment recipients

### 🔄 Pass Transformation

- Users can burn existing passes to receive new ones
- Supports upgrade paths and token evolution
- Operator-controlled transformations for managed ecosystems

### 🛡️ Security Features

- Role-based access control for administrative functions
- Pausable functionality for emergency situations
- Signature-based minting for secure off-chain authorization
- Meta-transaction support for better user experience

### 💸 Royalty Support

- ERC2981 royalty standard implementation
- Configure royalties for secondary market sales
- Set default royalties or override for specific pass types

## User Interactions

### For Pass Holders

- Mint passes using authorized signatures
- Transform existing passes into new pass types
- Transfer passes (if allowed by configuration)
- Use passes for access to services or content

### For Administrators

- Configure new pass types with custom properties
- Mint passes directly to users
- Update pass configurations and metadata
- Manage transferability and access control
- Pause/unpause contract functions in emergencies
- Recover accidentally sent tokens

## Technical Details

This contract implements several Ethereum standards:

- ERC1155: Multi-token standard
- ERC2981: NFT royalty standard
- ERC2771: Meta-transactions for gas-less operations

The contract is designed to be deployed behind a proxy for upgradeability,
allowing the functionality to evolve over time while maintaining the same
contract address and token balances.

---
Loading