approve
Contract: JBToken
Interface: IJBToken
- Step by step
- Code
- Errors
- Bug bounty
Approves an account to spend tokens on the msg.sender
s behalf.
Definition
function approve(
uint256 _projectId,
address _spender,
uint256 _amount
) external override { ... }
- Arguments:
_projectId
is the ID of the project to which the token belongs. This is ignored._spender
is the address that will be spending tokens on themsg.sender
s behalf._amount
is the amount the_spender
is allowed to spend.
- The function overrides a function definition from the
IJBToken
interface. - The function doesn't return anything.
Body
-
Make sure the project IDs match, or this contract's project ID is 0.
// Can't approve for a wrong project.
if (projectId != 0 && _projectId != projectId) revert BAD_PROJECT();Internal references:
-
Forward the call to the ERC20 implementation.
approve(_spender, _amount);
Inherited references:
/**
@notice
Approves an account to spend tokens on the `msg.sender`s behalf.
@param _projectId the ID of the project to which the token belongs. This is ignored.
@param _spender The address that will be spending tokens on the `msg.sender`s behalf.
@param _amount The amount the `_spender` is allowed to spend.
*/
function approve(
uint256 _projectId,
address _spender,
uint256 _amount
) external override {
// Can't approve for a wrong project.
if (projectId != 0 && _projectId != projectId) revert BAD_PROJECT();
approve(_spender, _amount);
}
String | Description |
---|---|
BAD_PROJECT | Thrown if the project being approved for is not compatible with this contract. |
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |