review
AAVEGOTCHI FAUCET Review
write a contract that acts as a disseminator allows specific addresses to mint a certificate. The predefined certs are already uploaded to ipfs(pinata). there is a supposed connection between user⇒id⇒ipfs
Assignment: https://github.com/jebitok-dev/autoyieldfarms/blob/main/contracts/UserYieldFarming.sol
add
function that requires at least the output of the sum of a & b will be greater than either a or b meaning its sum of whole numbers.subtract
function that allows the use of minus operator and subtract
function for unsigned integers that can allow signed integer that is greater than the other to subtract the other.multiplication
function that checks that if one number is equal to zero if multiplied returns zero and if multiplication of two equal numbers its division returns value equals to either of themdivision
function that checks division of two numbers and reverts any division of a number with zero. Also has a division function that requires that a number is greater than zero else gives an error message so division.modulo
function that uses the % operator returns the remainder of diving two unsigned integers and reverts operations that divide integer with zero which leaves gas unused ensuring divisor isn’t equal to zeromin
function that uses a ternary operator to check if the variables are equal or else than the other and pass a condition.totalSupply
function that returns the amount of tokens that exists i.e uint256decimals
function that returns the tokens in decimals i.e uint8symbol
function that returns the symbol of the tokenname
function that returns the name of the tokengetOwner
function that returns the address of the token ownerbalance
function that returns the number of tokens owned by the address ownertransfer
function that facilities the transaction of moving tokens it passes the recipient's address and the amount to be transferredallowance
function that passes the address of owner and the address spender allowed to spend on behalf of owner’s address. The value of the address changes when approve/transfer from functions are calledapprove
function which passes the address of spender and the amount to allowance to be spent and returns a bool which could be approval allowed or deniedtransferFrom
function that passes the addresses of sender and recipient and the amount of token and also returns a boolisContract
function which is a hashing function that passes the address of the account and returns a boolean. The account is hashed into accountHash which is of bytes32 of 64 char and is prefixed with 0x i.e hexadecimal string. and also an account that has not been generated is a codehash and to generate a new account it uses assembly. The generated address is ensured that it is not equal to the one that was hashed using keccak256 and is not the uncreated onesendValue
function that passes the address of the recipient which is payable(reduce gas fees) and the amount to be sent. It has a require statement that ensures that the account balance is greater or equal to the amount to be sent. It returns a bool that either transaction was successful or it was reverted either by the recipient or failed
functionCall
function that passes the address of the target and the data in memory(just used within the contract) and returns memory data i.e notifies when low-level calls fail. (could be an internal method defined to be used in another function)functionCall
function that passes the address of the target, data in memory, and the error message is an internal function and returns the memory data i.e it uses the functionCallWithValue method which is a method that was defined with this contract library that still passes the target address, data, value, and the error message or the low-level call failingfunctionCallWithValue
function which passes the address of the target, memory data, value, and error message, it requires that the address balance is greater than the value else sends an error message else returns a method which is a function i.e _functionCallWithValue which passes the target, data, value and error message_functionCallWithValue
requires that the target’s address is not hashed or uncreated account else pass an error message that it's not a contract address then it passes a bool and memory data it will make a low-level call i.e the value in Wei and the data if it's successful it emits the call else if the unsuccessful checks reason(balance) and reverts the transaction using memory through assemblyuses SafeBEP20
library that uses the SafeMath
and Address
Library defined within this contract. It has:
safeTransfer
function that passes an IBEP20 token, address of the receiver, and the value which is an internal function it uses _callOptionalReturn
method (define as a function within this library that is re-used in all the functions it passes the token, data in memory and data its a private function that defines the return data which is the token address then functionCall
is called to check its requirements to determine if the low-level call passes or not, to pass data) which passes the token, abi.encodewithselector that passes data variables i.e event token transferfrom selector, the address of the sender, address of the receiver and the valuesafeApprove
function with passes the IEP20 Token, address of spender and the value its an internal function that requires that the value is equal to zero or the token allowance balance of address of the spender from is equal to zero or send a message that SafeBEP20 is only approved for non-zero to non-zero allowance then calls the _callOptionalReturn
method that passes the token and abi.encodeWithSelector that passes variables the event that token approve selector, address pf spender and the valuesafeIncreaseAllowance
that passes that IBEP token, address of spender, and the value is an internal function that defines newAllowance which is token allowance which is assigned address and a spender whom a given value is added to them. It uses the _callOptionalReturn
method that stores the token, abi.encodeWithSelector that is feed data variables token approve selector, the spender and the newAllowance to increasesafeDecreaseAllowance
function which unlike the safeIncreaseAllowance
function passes the parameters and uses the same method but decreases the allowance using the given value.Context Contract that has:
_msgSender
function that returns a payable address and return statement is a low-level call msg.sender
_msgData
function that returns memory in bytes and return statement is a low-level call msg.data
Ownable Contract that is a Context Contract. It
OwnershipTransferred
which has indexed parameters: previous owners and the new ownerconstructor
function which is internal that has an address of the sender that’ll facilitate owner level call and its assigned to the owner and will emit OwnershipTransferred event of the index address & low-level callowner
function that returns an address i.e _owner by addressmsg.sender
can only call this contractrenounceOwnership
function that can only be accessed by the current owner and emits the OwnershipTransferred event that was declared that has parameters indexed owner & address so the owner will be equivalent to given indexed address if ownership is renouncedBEP20 Contract which is a Context, IBEP20, and Ownable Contract it uses the Safemath and Address Libraries. It has:
getOwner
function that’s an external function that returns an address and return statement is an ownername
function that returns a string and return statement is the name of the tokendecimals
function whose return statement is the decimalssymbol
function that returns a string i.e stringtotalSupply
function that returns the totalSupply of the tokenbalanceOf
function that passes the address of a given account and returns that balance of the accounttransfer
function that passes the address of the recipient and the amount to be transferred and returns a bool to be called it requires that its no a zero address and the amount will be transferred to the given address by the user or the transaction will fail(true/false...if it meets requirements)allowance
function that passes the address of the owner and that of the spender and returns an allowance that the owner can transfer/allow to the spenderTransferFrom
function that has the address of the sender, the address of the recipient, and the given amount that returns a boolean(true/false). _transfer method takes the sender’s address, recipient's address, and the amount whereas the _approve takes the sender’s address, the low-level call msg.sender(requires owner) and the allowances to be transferred to spender hence subtracting from the Owner’s amount of tokensdecreaseAllowance
function that passes the spender’s address and subtractedValue and the _approve method that executes low-level call, spender’s address, and the allowance from the owner to the spender then using sub-method from Safemath to subtract value from the owner. If the address is non-zero and the balance meets the condition it will return a true else falsemint
function that passes the amount to be minted and returns a bool. It uses the _mint method whose tokens are assigned to the owner with a given amount of tokens out of the mint_transfer
function that is defined and used in other functions within this contract its an internal function that passes the address of the sender and that of the recipient and the amount it requires that sender’s and recipient's addresses should not the zero index address. balance of the sender is equal to the amount subtracted by the allowance amount and the recipient's balance is equal to the actual balance added to the allowance from the sender_mint
function that is also used in the other functions within this contract passes the address of the account and the amount it also requires that the account should not be a zero-indexed address. The total supply is equal to the totalSupply plus the amount from the mint and the account balance equals the actual balance plus the amount added from the mint. This mint emits the Transfer method to the given zero index address, the account, and the given amount_burn
function that passes the account address and the amount it requires that the address of the account isn’t zero-indexed. The balance of the account is equal to the balance of the account subtracted by the amount from the burn and the total supply is equal to the total supply minus the amount as a result of a burn. This emits the transfer method who variables are the account, zero-indexed address and amount_approve
function that passes the address of the owner and that of spender and amount it requires that owner’s and recipient addresses are not zero-index addresses. The amount is equal to the allowance that the owner approves for a spender. This emits the Approval method that_burnFrom
function that passes the address of the account that contract will burn from, and the amount. _burn takes the account and amount and _approve takes account, the owner and the subtracts the allowance that the owner then burns the amount that exceeds the this. This function is used in the burn functionContract RigelToken is a BEP20 Token and it's a governance token. It has:
mint
function that passes the address of which token is minted and the amount this can only be called by the owner. _mint emit the amount to a given address and _moveDelegates passes index zero address(first), amount and adds it to delegates recordcheckpoint
struct that marks the fromBlock and the votesDomain Typehashing constant
: EIP712Domain of name, chainId, verifying contract using Keccak256Delegation Typehashing constant
: EIP712Delegation of delegatee, nonce, expirityDelegateChanged
that stores indexed delegator address, indexed address of fromDelegate and indexed address of toDelegate . It’s emitted when the account changes its delegateDelegateVotesChanged
which stores the indexed address of the delegate, previous balance, and new balance. Emitted when account balance changesdelegates
function that passes the address of delegator and returns an address of the delegator from _delegates recorddelegate
function that passes the address of delegated and has return statement _delegate with the msg.sender(the owner who’ll vote) and the delegatee(the address that delegates votes)getCurrentVotes
function that passes address of the account and returns uint256 value. Has nCheckPoints that checks the votes of the account. and return statement with terniray operator with condition if nCheckPoint is greater than 0 it will return the checkpoints of the account multiplied by the number of checks minus one multiplied by the votes else return zerogetPriorVotes
functions that passes the account’s address and the blocknumber which returns a uint256 value. it:_delegate
function used in other function within this contract passes the address of the delegator and address of delegatee._moveDelegates
functions that passes address of srcRep, address of dstRep and amount. If the srcRep is not equal and amount is greater than zero_writeCheckPoint
functions which passes the address of delagatee, nCheckpoints, oldVotes, newVotes.block.chainid
)// assembly was also used in the previous version of UniswapV2ERC20
// block.chainid wasn't yet implemented in solidity
uint chainId;
assembly {
chainId := chainid
}
MaterChef
Contract which is Ownable. It uses SafeMath and safeBEP20. It has:
deposit function that passes the _pid and the _amount:
withdraw
function that passes _pid and _amount and it requires that _pid is not equal to zero else returns an error message. The poolinfo is stored in the pool with the details of the specified id the userinfo is stored in the user with the user info of the given pid of the owner. It requires that the user’s amount should be greater than or equal to _maount else returns withdrawal error.
emergencyTransfer
function passes the _pid: the Poolinfo is stored as pool and has poolinfo of given pid whereas userinfo is stored as a user with the userinfo of given pid of the respective owner
safeRigelTransfer
function that passes address _to ad the given ammout its used in another functions with this contract the rigelBalance is equal to the balance of rigel of this address
dev function passes the _devaddr and the percentage it requires that the owner is equal to the devAdddr and the devaadr is reassigned to _devaddr then devPercentage equals to percentage
safeRigelWithdraw
functions that passes the address to and the amount and can only be called by the owner. The rigelBalance equals to the balance of Rigel in a given address if the _amount to be withdrawn is greater than the rigelbalance is traffered to the owner else user gets transfer of exact amount they specified