diff --git a/pages/store/implement5169.mdx b/pages/store/implement5169.mdx index f01510b..8f96b67 100644 --- a/pages/store/implement5169.mdx +++ b/pages/store/implement5169.mdx @@ -1,20 +1,22 @@ -# How to implement ERC5169 +# How to implement ERC-5169 -1. Install [stl-contracts](https://www.npmjs.com/package/stl-contracts) NPM module with command ```npm i stl-contracts``` +Implementing ERC-5169 can be conveniently achieved by inserting several lines of code. -2. Add next code to your contract +1. Install [stl-contracts](https://www.npmjs.com/package/stl-contracts) package: + +```sh npm2yarn copy +npm i stl-contracts ``` + +2. Add following code to your contract + +```solidity copy import "stl-contracts/ERC/ERC5169.sol"; contract ERC721Mint is Ownable, ERC5169, AccessControl, ERC721Enumerable { - function supportsInterface(bytes4 interfaceId) - public view override(ERC5169, ERC721Enumerable) - returns (bool) - { - return - ERC721Enumerable.supportsInterface(interfaceId) || - ERC5169.supportsInterface(interfaceId); + function supportsInterface(bytes4 interfaceId) public view override(ERC5169, ERC721Enumerable) returns (bool) { + return ERC721Enumerable.supportsInterface(interfaceId) || ERC5169.supportsInterface(interfaceId); } // limit set contracts to admin only @@ -22,20 +24,20 @@ contract ERC721Mint is Ownable, ERC5169, AccessControl, ERC721Enumerable { } ``` -3. In case if you don't implement **Ownable** interface then replace **onlyOwner** with your modifier to limit use of **_authorizeSetScripts** to admin or other user/group +3. In case if you don't implement **`Ownable`** interface then replace **`onlyOwner`** with your modifier to limit use of **`_authorizeSetScripts`** to admin or other user/group -4. When contract deployed run command to add script to your contract +4. When contract deployed run the following script to set the `scriptURI` -``` -let scripts = ["https://your.hosting.com/messaging_mumbai.tsml"] - +```js {8} copy const [owner] = await ethers.getSigners(); - -const ERC721Mint = await ethers.getContractFactory("ERC721Mint"); + +const ERC721Mint = await ethers.getContractFactory('ERC721Mint'); const nft = await ERC721Mint.attach(contractAddress); - -let tx = await nft.connect(owner).setScriptURI(scripts) + +let tx = await nft + .connect(owner) + .setScriptURI(['https://your.hosting.com/messaging_mumbai.tsml']); await tx.wait(); ``` -When script added then NFTs (which user own) for this contract will appear under [Smart Token Store](https://smart-token-store.vercel.app/) \ No newline at end of file +When script added then NFTs (which user own) for this contract will appear under [Smart Token Store](https://store.smartlayer.network/) diff --git a/pages/tokenscript/extra-features/token-messaging.mdx b/pages/tokenscript/extra-features/token-messaging.mdx index 63e9b3e..52f6098 100644 --- a/pages/tokenscript/extra-features/token-messaging.mdx +++ b/pages/tokenscript/extra-features/token-messaging.mdx @@ -1,24 +1,32 @@ # How to build Secure Messaging between ERC721 NFT owners -1. Install tokenscript CLI by running command ```npm i -g @tokenscript/cli``` +1. Clone Token Messaging template from the [Template Center](https://github.com/SmartTokenLabs/TokenScript-Templates) -2. Clone Git repo https://github.com/SmartTokenLabs/TokenScript-Templates - its list of TokenScript Templates +```sh copy +npx degit SmartTokenLabs/TokenScript-Templates/erc-721-messaging erc-721-messaging +``` -3. Open folder ```/erc-721-messaging``` +2. Open folder `/erc-721-messaging` -4. Replace Contract Address and chain ID in /tokenscript.xml, example: +3. Replace Contract Address and chain ID in /tokenscript.xml, example: -``` +```xml 0xe84Be2e18304AcF07ba2f11e37EABC321f4DC6Df ``` -5. Run command ```npm i``` to install all dependencies +4. Install TokenScript CLI: + +```sh npm2yarn copy +npm i -g @tokenscript/cli +``` + +5. Run command `npm i` to install all dependencies -6. Run command ```npm run build``` to build TSML file **out/tokenscript.tsml** +6. Run command `npm run build` to build TSML file **out/tokenscript.tsml** -7. Run ```tokenscript emulate``` to preview your tokenscript in action +7. Run `tokenscript emulate` to preview your tokenscript in action 8. If TokenScript works as expected then copy file **out/tokenscript.tsml** to some HTTPS hosting and save file URL @@ -26,11 +34,8 @@ Now you can use this URL in tokenscript viewer. Don't forget to replace variable This is template of TokenScript viewer for your TokenScript file: -``` +```sh https://viewer-staging.tokenscript.org/?chain=${chainId}&contract=${contractAddress}&tokenscriptUrl=${encodeURIComponent(tokenScriptFileURL)} ``` - - Thats it, ready for messaging. -