|
| 1 | +## Introduction <!-- {docsify-ignore} --> |
| 2 | + |
| 3 | + |
| 4 | +The `Solve3Verify.sol` contract is a critical component of the [Solve3](https://solve3.org) bot protection system. It enables you to verify Solve3 proofs and ensure secure interactions within your smart contracts. This documentation provides a detailed guide on integrating and using the `Solve3Verify` contract in your Ethereum-based projects. |
| 5 | + |
| 6 | +## Quick Start <!-- {docsify-ignore} --> |
| 7 | + |
| 8 | +Integrating the `Solve3Verify` contract into your project is a straightforward process. Here's a quick start guide: |
| 9 | + |
| 10 | +### Import Solve3Verify <!-- {docsify-ignore} --> |
| 11 | + |
| 12 | +Begin by importing the `Solve3Verify` contract into your Solidity project. |
| 13 | + |
| 14 | +```solidity |
| 15 | +import "@solve3/contracts/Solve3Verify.sol"; |
| 16 | +``` |
| 17 | + |
| 18 | +### Inherit from Solve3Verify <!-- {docsify-ignore} --> |
| 19 | + |
| 20 | +In your contract, inherit from the `Solve3Verify` contract. |
| 21 | + |
| 22 | +```solidity |
| 23 | +contract YourContract is Solve3Verify { |
| 24 | + // Your contract code here |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +### Initialize the Contract <!-- {docsify-ignore} --> |
| 29 | + |
| 30 | +In your contract's constructor, call the `__init_Solve3Verify` function with the address of the Solve3 Master contract as an argument. |
| 31 | + |
| 32 | +```solidity |
| 33 | +constructor(address _solve3Master) { |
| 34 | + __init_Solve3Verify(_solve3Master); |
| 35 | + // Your constructor code here |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +### Add solve3Verify modifier <!-- {docsify-ignore} --> |
| 40 | + |
| 41 | +To verify the proof created by Solve3 you have to add the `solve3Verify` modifier to your function and pass the `_proof` parameter. |
| 42 | + |
| 43 | +```solidity |
| 44 | +function foo(bytes memory _proof) external solve3Verify(_proof) { |
| 45 | + // Your function implementation |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +### Abstract Function disableSolve3 <!-- {docsify-ignore} --> |
| 50 | + |
| 51 | +Since Solve3 is in beta, you have to implement a function to disable Solve3 verification in your contract. |
| 52 | + |
| 53 | +!> Don't forget to add access control like OpenZeppelin `Ownable` |
| 54 | + |
| 55 | +```solidity |
| 56 | +function disableSolve3(bool _flag) external override onlyOwner { |
| 57 | + _disableSolve3(_flag); |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +Your contract is now ready to verify Solve3 proofs for secure interactions. |
| 62 | + |
| 63 | +## Advanced Options |
| 64 | + |
| 65 | +The `Solve3Verify` contract provides optional functions to enhance flexibility and control in your project based on your personal needs or the chain you want to deploy to. |
| 66 | + |
| 67 | +### Set Valid From Timestamp |
| 68 | + |
| 69 | +To customize the timestamp from which the signature is valid, you can implement the following internal function: |
| 70 | + |
| 71 | +```solidity |
| 72 | +function _setValidFromTimestamp(uint256 _validFromTimestamp) internal { |
| 73 | + validFromTimestamp = _validFromTimestamp; |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +This function allows you to adjust the timestamp based on your specific requirements. |
| 78 | + |
| 79 | +**Note:** Per default the `validFromTimestamp` is set to timestamp of the contract deployment. |
| 80 | + |
| 81 | +### Set Valid Period Seconds |
| 82 | + |
| 83 | +You can modify the period in seconds for which the signature is valid using this internal function: |
| 84 | + |
| 85 | +```solidity |
| 86 | +function _setValidPeriodSeconds(uint256 _validPeriodSeconds) internal { |
| 87 | + validPeriodSeconds = _validPeriodSeconds; |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +Use this function to change the period for which the signature remains valid. |
| 92 | + |
| 93 | +**Note:** Per default the `validPeriodSeconds` is set to 300 seconds. |
| 94 | + |
| 95 | +Developers can customize the `validFrom` and `validPeriod` functionality by overriding the following functions: |
| 96 | + |
| 97 | +### Custom validFrom Implementation |
| 98 | + |
| 99 | +`function validFrom() public view virtual returns (uint256)` |
| 100 | + |
| 101 | +This overridable function allows developers to modify the timestamp from which the signature is considered valid. |
| 102 | + |
| 103 | +```solidity |
| 104 | +function validFrom() public view virtual returns (uint256) { |
| 105 | + // Custom logic to determine the validFrom timestamp |
| 106 | + return yourCustomValidFromTimestamp; |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +### Custom validPeriod Implementation |
| 111 | + |
| 112 | + `function validPeriod() public view virtual returns (uint256)` |
| 113 | + |
| 114 | + This overridable function enables developers to change the period in seconds for which the signature remains valid. |
| 115 | + |
| 116 | +```solidity |
| 117 | +function validPeriod() public view virtual returns (uint256) { |
| 118 | + // Custom logic to determine the valid period in seconds |
| 119 | + return yourCustomValidPeriodSeconds; |
| 120 | +} |
| 121 | +``` |
| 122 | + |
| 123 | +These functions provide flexibility for developers to adapt Solve3 verification to their specific project requirements. |
| 124 | + |
| 125 | + |
| 126 | +## Public Variables and View Functions |
| 127 | + |
| 128 | +The `Solve3Verify` contract includes various public variables and view functions for inspecting its state. These include: |
| 129 | + |
| 130 | +* `public solve3Master`: The address of the Solve3 Master contract. |
| 131 | +* `public solve3Disabled`: A flag indicating whether Solve3 verification is disabled. |
| 132 | +* `public validFromTimestamp`: The timestamp from which the signature is valid. |
| 133 | +* `public validPeriodSeconds`: The period in seconds for which the signature is valid. |
0 commit comments