On Chain Token Authentication (evm)

Authenticating on chain tokens

The following solution utilises EVM Web3 Wallet Signature technology to sign a custom defined message which, once signed can be decoded to ensure the integrity of the wallet owner and the tokens they hold.

  1. Request signature:

const signature = await negotiator.web3WalletProvider.signMessage(
    walletAddress, 
    SigningMessage
)
  1. Define an array of tokens the user must hold as part of your authentication rules:

const claim =[{"smartContract":"0x94e22c14118353651636f9af43cd0a5a08b93da3","chain":"fantom","blockChain":"evm"}]

(include tokenids: [1,3,10] into the claim collection(s) when the user must have specific token(s))

  1. Verify the owner of the wallet an the claim of tokens they hold (use the following api server side to ensure the request and response is not manipulated by the end user (Client-side CSRF):

https://api.token-discovery.tokenscript.org/get-token-verification?claim=[{"smartContract":"0x94e22c14118353651636f9af43cd0a5a08b93da3","chain":"fantom","blockChain":"evm"}]&signature=0x4c8be3f2039b74e830c8febdd7d51df6db0d29e17845bec0b1f3cf8ec85579904d8b441144ddbac88fcea7b86fb03b16395aaeb2b254b836d800d45261db067d2c&message=hello-web3

Last updated