-
-
Save nazt/5379d82da5f71af4d9abcafaa23d48ca to your computer and use it in GitHub Desktop.
Revisions
-
dievardump revised this gist
Sep 3, 2021 . 1 changed file with 32 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,34 +3,52 @@ pragma solidity ^0.8.0; /// @title OpenSea contract helper that defines a few things /// @author Simon Fremaux (@dievardump) /// @dev This is a contract used to add OpenSea's /// gas-less trading and contractURI support contract BaseOpenSea { string private _contractURI; address private _proxyRegistry; /// @notice Returns the contract URI function. Used on OpenSea to get details // about a contract (owner, royalties etc...) function contractURI() public view returns (string memory) { return _contractURI; } /// @notice Returns the current OS proxyRegistry address registered function proxyRegistry() public view returns (address) { return _proxyRegistry; } /// @notice Helper allowing OpenSea gas-less trading by verifying who's operator /// for owner /// @dev Allows to check if `operator` is owner's OpenSea proxy on eth mainnet / rinkeby /// or to check if operator is OpenSea's proxy contract on Polygon and Mumbai /// @param owner the owner we check for /// @param operator the operator (proxy) we check for function isOwnersOpenSeaProxy(address owner, address operator) public view returns (bool) { address proxyRegistry_ = _proxyRegistry; // if we have a proxy registry if (proxyRegistry_ != address(0)) { // on ethereum mainnet or rinkeby use "ProxyRegistry" to // get owner's proxy if (block.chainid == 1 || block.chainid == 4) { return address(ProxyRegistry(proxyRegistry_).proxies(owner)) == operator; } else if (block.chainid == 137 || block.chainid == 80001) { // on Polygon and Mumbai just try with OpenSea's proxy contract // https://docs.opensea.io/docs/polygon-basic-integration return proxyRegistry_ == operator; } } return false; } /// @dev Internal function to set the _contractURI @@ -42,7 +60,7 @@ contract BaseOpenSea { /// @dev Internal function to set the _proxyRegistry /// @param proxyRegistryAddress the new proxy registry address function _setOpenSeaRegistry(address proxyRegistryAddress) internal { _proxyRegistry = proxyRegistryAddress; } } -
dievardump renamed this gist
Sep 1, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import "./OpenSea/BaseOpenSea.sol"; /// @title Example of usage of BaseOpenSea /// @author Simon Fremaux (@dievardump) /// @notice This contract is only an example of how I implement BaseOpenSea contract MyERC1155 is Ownable, ERC1155, BaseOpenSea @@ -18,7 +18,7 @@ contract My1155 is /// @param uri_ - the contract base uri /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry /// @param contractURI_ - the contract metadata URI (https://docs.opensea.io/docs/contract-level-metadata) constructor(string memory uri_, address openSeaProxyRegistry, string memory contractURI_) ERC1155(uri_) { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); } -
dievardump revised this gist
Sep 1, 2021 . 2 changed files with 51 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "./OpenSea/BaseOpenSea.sol"; /// @title Example of usage of BaseOpenSea /// @author Simon Fremaux (@dievardump) /// @notice This contract is only an example of how I implement BaseOpenSea contract My1155 is Ownable, ERC1155, BaseOpenSea { /// @notice constructor /// @param uri_ - the contract base uri /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry /// @param contractURI_ - the contract metadata URI (https://docs.opensea.io/docs/contract-level-metadata) constructor(string memory uri_, address openSeaProxyRegistry, string memory contractURI_) ERC155(uri_) { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); } if (bytes(contractURI_).length > 0) { _setContractURI(contractURI_); } } /// @notice Allows gas-less trading on OpenSea by safelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to check first if current operator is owner's OpenSea proxy /// @inheritdoc ERC1155 function isApprovedForAll(address owner, address operator) public view override returns (bool) { // allows gas less trading on OpenSea return super.isApprovedForAll(owner, operator) || isOwnersOpenSeaProxy(owner, operator); } /// @notice Helper for the owner of the contract to set the new contract URI /// @dev caller needs to be owner /// @param contractURI_ new contract URI function setContractURI(string memory contractURI_) external onlyOwner { _setContractURI(contractURI_); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import "./OpenSea/BaseOpenSea.sol"; /// @title Example of usage of BaseOpenSea /// @author Simon Fremaux (@dievardump) /// @notice This contract is only an example of how I implement BaseOpenSea contract MyERC721 is Ownable, ERC721, BaseOpenSea -
dievardump revised this gist
Aug 1, 2021 . 3 changed files with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,8 @@ contract BaseOpenSea { ProxyRegistry private _proxyRegistry; /// @notice Returns the contract URI function. Used on OpenSea to get details /// about a contract (owner, royalties etc...) /// See documentation: https://docs.opensea.io/docs/contract-level-metadata function contractURI() public view returns (string memory) { return _contractURI; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ contract MyNFT is { /// @notice constructor /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry /// @param contractURI_ - the contract metadata URI (https://docs.opensea.io/docs/contract-level-metadata) constructor(address openSeaProxyRegistry, string memory contractURI_) ERC721('MyNFT', 'NFT') { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,14 @@ Those two files allow to have easy gas-less trading on OpenSea # Registries OpenSea Proxyregistry addresses: Mainnet: 0xa5409ec958c83c3f309868babaca7c86dcb077c1 Rinkeby: 0xf57b2c51ded3a29e6891aba85459d600256cf317 # Contract level metadata with `contractURI()` https://docs.opensea.io/docs/contract-level-metadata -
dievardump revised this gist
Aug 1, 2021 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ # Gas-Less trading Those two files allow to have easy gas-less trading on OpenSea # Registries OpenSea Proxyregistry addresses: Mainnet: 0xa5409ec958c83c3f309868babaca7c86dcb077c1 Rinkeby: 0xf57b2c51ded3a29e6891aba85459d600256cf317 -
dievardump revised this gist
Aug 1, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ Those two files allow to have easy gas-less trading on OpenSea OpenSea Proxyregistry addresses: Mainnet: 0xa5409ec958c83c3f309868babaca7c86dcb077c1 Rinkeby: 0xf57b2c51ded3a29e6891aba85459d600256cf317 -
dievardump revised this gist
Aug 1, 2021 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ OpenSea Proxyregistry addresses: Mainnet: 0xa5409ec958c83c3f309868babaca7c86dcb077c1 Rinkeby: 0xf57b2c51ded3a29e6891aba85459d600256cf317 -
dievardump revised this gist
Aug 1, 2021 . 2 changed files with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; /// @title OpenSea contract helper that defines a few things /// @author Simon Fremaux (@dievardump) /// @dev This is a contract used to add OpenSea's support for gas-less trading /// by checking if operator is owner's proxy contract BaseOpenSea { string private _contractURI; ProxyRegistry private _proxyRegistry; @@ -26,7 +26,7 @@ contract BaseOpenSea { { ProxyRegistry proxyRegistry = _proxyRegistry; return // we have a proxy registry address address(proxyRegistry) != address(0) && // current operator is owner's proxy address address(proxyRegistry.proxies(owner)) == operator; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ contract MyNFT is /// @notice Allows gas-less trading on OpenSea by safelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to check first if current operator is owner's OpenSea proxy /// @inheritdoc ERC721 function isApprovedForAll(address owner, address operator) public view -
dievardump revised this gist
Aug 1, 2021 . 1 changed file with 2 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,19 +3,12 @@ pragma solidity ^0.8.0; /// @title OpenSea contract helper that defines a few things /// @author Simon Fremaux (@dievardump) /// @dev This is a contract used to add OpenSea's gas-less trading support /// by verifying if the operator is current owner's Proxy. contract BaseOpenSea { string private _contractURI; ProxyRegistry private _proxyRegistry; /// @notice Returns the contract URI function. Used on OpenSea to get details // about a contract (owner, royalties etc...) function contractURI() public view returns (string memory) { -
dievardump revised this gist
Jul 19, 2021 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,11 +37,7 @@ contract MyNFT is returns (bool) { // allows gas less trading on OpenSea return super.isApprovedForAll(owner, operator) || isOwnersOpenSeaProxy(owner, operator); } /// @notice Helper for the owner of the contract to set the new contract URI -
dievardump revised this gist
Jun 30, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ contract MyNFT is /// @notice constructor /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry /// @param contractURI_ - the contract metadata URI constructor(address openSeaProxyRegistry, string memory contractURI_) ERC721('MyNFT', 'NFT') { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); } -
dievardump revised this gist
Jun 13, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ pragma solidity ^0.8.0; /// @title OpenSea contract helper that defines a few things /// @author Simon Fremaux (@dievardump) /// @dev This is a contract used to add OpenSea's support /// This is a contract made to work with upgradeable contract, /// if you ever add state variables, you must update __gap accordingly. -
dievardump revised this gist
Jun 12, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,8 @@ import "./OpenSea/BaseOpenSea.sol"; /// @author Simon Fremaux (@dievardump) /// @notice This contract is only an example of how I implement BaseOpenSea contract MyNFT is Ownable, ERC721, BaseOpenSea { /// @notice constructor -
dievardump revised this gist
Jun 12, 2021 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,10 +15,15 @@ contract MyNFT is { /// @notice constructor /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry /// @param contractURI_ - the contract metadata URI function constructor(address openSeaProxyRegistry, string memory contractURI_) ERC721('MyNFT', 'NFT') { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); } if (bytes(contractURI_).length > 0) { _setContractURI(contractURI_); } } /// @notice Allows gas-less trading on OpenSea by safelisting the ProxyRegistry of the user -
dievardump revised this gist
Jun 12, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ contract MyNFT is } /// @notice Allows gas-less trading on OpenSea by safelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to check first if current operator is owner's OpenSea proxy /// @inheritdoc ERC721Upgradeable function isApprovedForAll(address owner, address operator) public -
dievardump revised this gist
Jun 12, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,7 @@ contract MyNFT is } } /// @notice Allows gas-less trading on OpenSea by safelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. /// @inheritdoc ERC721Upgradeable function isApprovedForAll(address owner, address operator) -
dievardump revised this gist
Jun 12, 2021 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,12 @@ contract MyNFT is BaseOpenSea { /// @notice constructor /// @param openSeaProxyRegistry - the address of OpenSea Proxy Registry function constructor(address openSeaProxyRegistry) ERC721('MyNFT', 'NFT') { if (openSeaProxyRegistry != address(0)) { _setOpenSeaRegistry(openSeaProxyRegistry); } } /// @notice Allows gas-less trading on OpenSea by whitelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. -
dievardump created this gist
Jun 12, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title OpenSea contract helper that defines a few things /// @author Simon Fremaux (@dievrarump) /// @dev This is a contract used to add OpenSea's support /// This is a contract made to work with upgradeable contract, /// if you ever add state variables, you must update __gap accordingly. /// -> https://forum.openzeppelin.com/t/what-exactly-is-the-reason-for-uint256-50-private-gap/798 /// if you do not use Upgradeable contracts, you should comment the line that defines __gap contract BaseOpenSea { string private _contractURI; ProxyRegistry private _proxyRegistry; /// @dev If you ever add new state variable please add BEFORE this comment, and update __gap accordingly /// @dev https://forum.openzeppelin.com/t/what-exactly-is-the-reason-for-uint256-50-private-gap/798 uint256[10] private __gap; /// @notice Returns the contract URI function. Used on OpenSea to get details // about a contract (owner, royalties etc...) function contractURI() public view returns (string memory) { return _contractURI; } /// @notice Helper for OpenSea gas-less trading /// @dev Allows to check if `operator` is owner's OpenSea proxy /// @param owner the owner we check for /// @param operator the operator (proxy) we check for function isOwnersOpenSeaProxy(address owner, address operator) public view returns (bool) { ProxyRegistry proxyRegistry = _proxyRegistry; return // we have a proxy address address(proxyRegistry) != address(0) && // current operator is owner's proxy address address(proxyRegistry.proxies(owner)) == operator; } /// @dev Internal function to set the _contractURI /// @param contractURI_ the new contract uri function _setContractURI(string memory contractURI_) internal { _contractURI = contractURI_; } /// @dev Internal function to set the _proxyRegistry /// @param proxyRegistryAddress the new proxy registry address function _setOpenSeaRegistry(address proxyRegistryAddress) internal { _proxyRegistry = ProxyRegistry(proxyRegistryAddress); } } contract OwnableDelegateProxy {} contract ProxyRegistry { mapping(address => OwnableDelegateProxy) public proxies; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "./OpenSea/BaseOpenSea.sol"; /// @title Example of usage of BaseOpenSea /// @author Simon Fremaux (@dievardump) /// @notice This contract is only an example of how I implement BaseOpenSea contract MyNFT is Ownable BaseOpenSea { /// @notice constructor function constructor() ERC721('MyNFT', 'NFT') {} /// @notice Allows gas-less trading on OpenSea by whitelisting the ProxyRegistry of the user /// @dev Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings. /// @inheritdoc ERC721Upgradeable function isApprovedForAll(address owner, address operator) public view override returns (bool) { // allows gas less trading on OpenSea if (isOwnersOpenSeaProxy(owner, operator)) { return true; } return super.isApprovedForAll(owner, operator); } /// @notice Helper for the owner of the contract to set the new contract URI /// @dev caller needs to be owner /// @param contractURI_ new contract URI function setContractURI(string memory contractURI_) external onlyOwner { _setContractURI(contractURI_); } }