🧠Smart Contract

This is a quick guide to deploy clu3 smart contract to the blockchain.

If you are here, you already made it! So congrats for that πŸŽ‰.

In your Solidity contract, you will need to import clu3 contract, that can be found here.

import 'clu3.sol';

Then on your smart contract, you will use the function called useclu3 on the function that you want to protect! βš”οΈ

// useclu3 function has two parameters. (uint256 _timestamp, bytes memory signature)
function useclu3(uint256 _timestamp, bytes memory signature) public returns(bool) {
        bytes32 message = keccak256(abi.encodePacked(msg.sender, _timestamp, cluID));
        if(recoverSigner(message, signature) == publicKey) {
            if(checkStorage(Strings.toString(_timestamp))){
                return true;
            } else {
                revert("timestamp + cluID already used");
            }
        }
        revert("Invalid signature");

This function is going to build the message on chain, and see if the signature is valid. If it is valid we will proceed to check if the timestamp was already used. If not, we return true and continue with the function, else with revert.

Deploying the smart contract

To deploy the smart contract to the blockchain you will need to add to the clu3 function two parameters.

address _publicKey = //You need to put the public key of the wallet that you used the private key in the backend
uint256 _cluID = // To avoid cross usage when same sign is multi-used

Once the contract is deployed, you are done. Thanks for using clu3!

If you have any questions about how to implement clu3 in your own, don't hesitate in contacting us

Last updated