Links
Comment on page
👀

Integrate Algoz

Note: If you get stuck feel free to book a call with the team here.

1) Import Algoz in your smart contract

❇️ Import the Algoz smart contract in your code. It can be found on our Github here.
import "./Algoz.sol";

2) Initialize Algoz constructor

constructor(address _token_verifier, bool _verify_enabled, uint _proof_ttl)
Algoz(_token_verifier, _verify_enabled, _proof_ttl) {}
❇️ These 3 parameters are explained in detail under the Variables section.

3) Prevent spam :)

validate_token(expiry_token, auth_token, signature_token);
❇️ Add this statement inside the function that needs to be authenticated, look at the example contract given below.
Note: These 2 parameters are provided by the Algoz API

Example Counter Contract

❇️ Before Algoz
pragma solidity >=0.8.4;
contract Counter {
uint public count;
constructor() {}
// increment by 1, function to be protected by spam
function increment() public {
count += 1;
}
}
❇️ After Algoz (3 more lines of code)
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "./Algoz.sol";
contract Counter is Algoz {
uint public count;
constructor(address _token_verifier, bool _verify_enabled, uint _proof_ttl)
Algoz(_token_verifier, _verify_enabled, _proof_ttl) {}
// increment by 1, function to be protected by spam
function increment(bytes32 expiry_token, bytes32 auth_token, bytes calldata signature_token) public {
// algoz token validation
validate_token(expiry_token, auth_token, signature_token);
count += 1;
}
}