Appearance
Props Diamond SDK
A powerful SDK for interacting with Props Diamond smart contracts, built on the Diamond Standard (EIP-2535).
Overview
Props Diamond SDK provides a seamless interface for developers to interact with Props Diamond contracts, including ERC721, ERC1155, ERC7401 and ERC6220 implementations. This SDK simplifies the process of managing dynamic NFTs and their associated catalogs.
Installation
Available through npm, yarn, or pnpm package managers. Install using your preferred package manager.
What is it?
Developers can use the Props Diamond SDK to:
- Create a new, empty Diamond clone via the Props Diamond Factory, and initialize any facets at time of deployment in one transaction.
- Add/Remove/Update facets on their Diamond.
- Interact with their Diamond by sdk.diamondManager.generateDiamondABI() or even simpler sdk.diamondManager.getCallableContractForDiamond()
- Serialize their diamond configuration (json), including contract addresses and installed facet data
- Load serialized configurations (json) from file, db, etc
Quick Start
Install the Props Diamond SDK (not yet published)
bash
pnpm add @props-labs/diamond-sdkInstantiate an instance of the sdk
typescript
const propsDiamondSDKClient = new PropsDiamondSDK({
signer: wallet, //ethers wallet
networkConfiguration: {
provider: ethers.getDefaultProvider(), // provider
},
platformConfiguration: {
platform: {
propsDiamondFactory: "", //address of Props Diamond Factory
facetCatalog: FacetCatalog, //FacetCatalog Type, holds all of the available facets
},
},
});Pick the facets you want to install into the Diamond:
typescript
const baseFacets =
await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
["DiamondLoupeFacet", "PropsERC1155"]
);Create the diamond cuts for the selected facets:
typescript
const propsERC1155Cuts: DiamondCut[] =
await propsDiamondSDKClient.diamondManager.createDiamondCuts(
FacetCutAction.Add, //We'll add these facets to the diamond
baseFacets, //our selected facets from the catalog
[], // ONLY install these facets if set, otherwise all functions from the selected facets will be added to cut
["uri(uint256)", "mint(address,uint256,uint256)", "mintBatch(address,uint256[],uint256[])"], // Exclude these functions from the cut
{} // if selected facet contracts have overlapping function signatures, establish which contract takes priority
);Add additional facets and cuts:
typescript
// Royalty Facet
const royaltyFacet =
await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
["PropsRoyalty"]
);
// Create royalty facet cuts
const propsRoyaltyCuts: DiamondCut[] =
await propsDiamondSDKClient.diamondManager.createDiamondCuts(
FacetCutAction.Add,
royaltyFacet,
["royaltyInfo(uint256,uint256)", "setTokenRoyalty(uint256,address,uint96)", "getDefaultRoyaltyBips()"], //only adding these functions
[],
{}
);
// Airdrop facet
const airdropFacet =
await propsDiamondSDKClient.platformManager.catalogManager.getFacetCatalogFacetsByNames(
["PropsERC1155Airdrop"]
);
// Create airdrop facet cuts
const airdropFacetCuts: DiamondCut[] =
await propsDiamondSDKClient.diamondManager.createDiamondCuts(
FacetCutAction.Replace,
airdropFacet,
["batchMintAirdrop(uint256[],address[],uint256[])"], //only adding this function
[],
{}
);
// Combine all cuts into one DiamondCut[]
const cuts: DiamondCut[] = [
...propsERC1155Cuts,
...airdropFacetCuts,
...propsRoyaltyCuts,
];Deploy the diamond from clone, with facets, and init functions to initialize any facet(s) in one txn:
typescript
await propsDiamondSDKClient.diamondManager.deployDiamondCloneWithCuts(
cuts, // our combined DiamondCut[]
[
// Initialize the ERC1155
await propsDiamondSDKClient.diamondManager.createFacetInit(
"PropsERC1155",
"init",
[
"NAME",
"SYMBOL",
"DESCRIPTION",
"ipfs://baseuricid/",
"ipfs://contracturicid",
0
]
),
// Initialize the Royalty Facet - setting default BIPs on royalties
await propsDiamondSDKClient.diamondManager.createFacetInit(
"PropsRoyalty",
"init",
[1000] // 1000 BPS = 10%
),
]
);Use the diamond:
typescript
diamondContract = await propsDiamondSDKClient.diamondManager.getCallableContractForDiamond();
// read the erc1155 name
const erc1155name = await diamondContract.name();
// mint an erc1155 token
const tx = await diamondContract.connect(SDKFixture.signers.collector).mint(
recipientAddress,
tokenId,
quantity,
{ value: totalMintCost }
);Key Features
- Full TypeScript support
- Easy integration with Props Diamond contracts
- Built-in support for ERC721, ERC1155, ERC7401 and ERC6220 standards
- Platform management utilities
- Comprehensive error handling
- Gas-efficient contract interactions
Documentation
For detailed documentation, examples, and API reference, visit our official documentation site at diamond-docs.props.app.
Core Components
PlatformManager
The main class for interacting with Props Diamond contracts. Provides methods for:
- Managing assets and collections
- Interacting with catalogs
- Handling token operations
- Managing platform configurations
ContractManager
Handles low-level contract interactions and provides:
- Contract deployment utilities
- Diamond facet management
- Contract upgrades and maintenance
Usage Guidelines
- Initialize the SDK with your preferred provider
- Configure network settings before operations
- Handle errors using provided error types
- Follow best practices for gas optimization
Best Practices
- Always initialize with appropriate network settings
- Implement proper error handling
- Use TypeScript for better development experience
- Follow the documentation for optimal implementation
Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- GitHub Issues: github.com/Props-Labs/props-diamond-protocol
- Discord Community: discord.gg/Vkdu8UfXa7
Security
For security concerns, please email [email protected] or submit an issue.