Advance
Extra Features
Token Messaging

How to build Secure Messaging between ERC721 NFT owners

  1. Clone Token Messaging template from the Template Center (opens in a new tab)
npx degit SmartTokenLabs/TokenScript-Templates/erc-721-messaging erc-721-messaging
  1. Open folder /erc-721-messaging

  2. 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>
  1. Install TokenScript CLI:
npm i -g @tokenscript/cli
  1. Run command npm i to install all dependencies

  2. Run command npm run build to build TSML file out/tokenscript.tsml

  3. Run tokenscript emulate to preview your tokenscript in action

  4. 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.