Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "erc7656", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "ERC7656 Reference Implementation", | ||
@@ -29,4 +29,5 @@ "publishConfig": { | ||
"dependencies": { | ||
"@openzeppelin/contracts": "^5.0.2", | ||
"erc6551": "^0.3.1" | ||
} | ||
} |
@@ -18,3 +18,48 @@ # ERC-7656 | ||
Install it as a dependency | ||
``` | ||
npm i erc7656 @openzeppelin/contracts erc6551 | ||
``` | ||
Make your nft able to deploy plugins | ||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
// Compatible with OpenZeppelin Contracts ^5.0.0 | ||
pragma solidity ^0.8.20; | ||
import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "erc7656/utils/ERC7656Deployer.sol"; | ||
contract MyExpandableToken is ERC721, Ownable, ERC7656Deployer { | ||
error NotTheTokenOwner(); | ||
constructor(address initialOwner) | ||
ERC721("MyExpandableToken", "MET") | ||
Ownable(initialOwner) { | ||
} | ||
function safeMint(address to, uint256 tokenId) public onlyOwner { | ||
_safeMint(to, tokenId); | ||
} | ||
function deployContractsOwnedByTheTokenId( | ||
address implementation, | ||
bytes32 salt, | ||
uint256 tokenId | ||
) external payable virtual override { | ||
if (_msgSender() != ownerOf(tokenId)) revert NotTheTokenOwner(); | ||
// passing address(0) as the manager address, since the token is the manager | ||
_deploy(implementation, salt, address(this), tokenId, address(0)); | ||
} | ||
} | ||
``` | ||
For more elaborate example, take a look at the [Cruna Protocol](https://github.com/crunaprotocol/cruna-protocol). | ||
Notice that the plugin can be deployed by anyone, not only by the owner. Deploying it from the token itself, however, allows for more controls; for example, if executing an initializing function allowed only by the token owner. | ||
## License | ||
@@ -21,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12543
69
2
+ Added@openzeppelin/contracts@5.1.0(transitive)