How to build Secure Messaging between ERC721 NFT owners
- Clone Token Messaging template from the Template Center (opens in a new tab)
npx degit SmartTokenLabs/TokenScript-Templates/erc-721-messaging erc-721-messaging
-
Open folder
/erc-721-messaging
-
Replace Contract Address and chain ID in /tokenscript.xml, example:
<ts:contract interface="erc721" name="Token">
<ts:address network="80001">0xe84Be2e18304AcF07ba2f11e37EABC321f4DC6Df</ts:address>
</ts:contract>
- Install TokenScript CLI:
npm i -g @tokenscript/cli
-
Run command
npm i
to install all dependencies -
Run command
npm run build
to build TSML file out/tokenscript.tsml -
Run
tokenscript emulate
to preview your tokenscript in action -
If TokenScript works as expected then copy file out/tokenscript.tsml to some HTTPS hosting and save file URL
Now you can use this URL in tokenscript viewer. Don't forget to replace variables with values chainId , contractAddress and replace tokenScriptFileURL with its value, its URL, where TSML file located.
This is template of TokenScript viewer for your TokenScript file:
https://viewer-staging.tokenscript.org/?chain=${chainId}&contract=${contractAddress}&tokenscriptUrl=${encodeURIComponent(tokenScriptFileURL)}
Thats it, ready for messaging.