Signature verification example in solidity with changing hash every 2 minutes for more security.
- The hash is generated by the smart contract using these:
- Address of the deployed smart contract
- Chain Id
- Current nonce: Changes after every successful transaction
- Hash timestamp: Timestamp which changes every 2 minutes
- This hash will be signed by the signer and the signature can be used in transactions.
- After a successful transaction the hash will be marked as executed and the nonce will be updated. This will prevent signature replay attacks.
- Apart from this the hash to be signed will keep changing every 2 mintues for more security.
- Clone the repo
git clone https://github.com/codeTIT4N/solidity-signature-changing-hash
- Install
node_modules
npm install
- Compile smart contract
npx hardhat compile
- Run the test cases
npx hardhat test