StartGrant.sol
StartGrant.sol is an executive law that enables the initiation of grant programs. It provides a mechanism to set up and start new grant distributions with specific parameters and conditions.
Overview
This law provides a mechanism to:
Initialize grant programs
Set grant parameters and conditions
Configure grant distribution rules
Track grant program status
Enforce grant rules
Configuration
When adopting a StartGrant instance, four parameters must be provided:
grantToken
(address): The token to be distributed as grantstotalAmount
(uint256): Total amount of tokens to be distributedduration
(uint256): Duration of the grant programmaxRecipients
(uint256): Maximum number of grant recipients
Usage
Proposing an Action
When calling the law, three parameters must be provided:
recipient
(address): The address to receive the grantamount
(uint256): Amount of tokens to grantstart
(bool):true
: Start the grant programfalse
: Cancel grant program start
Execution Flow
Grant Validation
Verifies grant parameters
Validates recipient eligibility
Checks grant conditions
Grant Initialization
If
start
is true:Initializes grant program
Sets up distribution parameters
Records grant details
If
start
is false:Cancels grant program
Updates program status
State Management
Updates grant registry
Maintains recipient list
Tracks grant status
Technical Specifications
State Variables
struct Data {
address grantToken; // Token to be distributed
uint256 totalAmount; // Total grant amount
uint256 duration; // Program duration
uint256 maxRecipients; // Max number of recipients
address[] recipients; // List of grant recipients
mapping(address => uint256) grantAmounts; // Amount per recipient
mapping(address => uint256) grantStartTime; // When grant started
}
mapping(bytes32 lawHash => Data) public data;
Functions
initializeLaw
initializeLaw
function initializeLaw(
uint16 index,
string memory nameDescription,
bytes memory inputParams,
Conditions memory conditions,
bytes memory config
) public override
Initializes law with configuration parameters
Sets up grant parameters
Initializes empty recipient tracking
handleRequest
handleRequest
function handleRequest(
address caller,
address powers,
uint16 lawId,
bytes memory lawCalldata,
uint256 nonce
) public view virtual override returns (
uint256 actionId,
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
bytes memory stateChange
)
Processes the grant request
Validates grant parameters
Prepares grant distribution
Returns execution data
Error Conditions
Grant Errors
"Invalid grant amount"
"Max recipients reached"
"Grant already started"
Recipient Errors
"Invalid recipient"
"Recipient already has grant"
"Invalid recipient amount"
Validation Errors
Invalid token address
Invalid grant parameters
Zero address recipient
Invalid grant status
Current Deployments
Previous Deployments
Last updated