Energy Rental
Introduction
All transactions on JustLend DAO require Energy, which can only be acquired through staking or burning TRX. This process involves high costs and lengthy procedures. In response, JustLend DAO introduces the Energy Rental service, allowing users to rent Energy at a significantly reduced price compared to staking or burning TRX. The contract EnergyRental used to set up the Energy Rental service.
Solidity API
Query Interface
Query Rental order information
View the information of an order.
Parameter description:
Parameter | Type | Description |
---|---|---|
renter | address | Rent payer |
receiver | address | Resource receiver |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
Returns Values:
Field | Type | Description |
---|---|---|
amount | uint256 | Order resources corresponding to the number of TRX |
securityDeposit | uint256 | Order deposit, not updated to current |
rentIndex | uint256 | Order's global index at the time of its last update |
Query current rental order information (updated to current)
View the information of an order, with the returned data updated to current.
Parameter description:
Parameter | Type | Description |
---|---|---|
renter | address | Rent payer |
receiver | address | Resource receiver |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
Returns Values:
Field | Type | Description |
---|---|---|
[0] securityDeposit | uint256 | Order deposit, updated to current |
[1] rentIndex | uint256 | Real-time global index of the order at the time of query |
Write Interface
Rent resources
Rent resources, allow amount = 0 (extension only) or msg.value = 0 (no new deposit), both are 0 is not allowed.
Parameter description:
Parameter | Type | Description |
---|---|---|
msg.sender | The payer for this rental | |
receiver | address | The resource receiver of this rental Not allowed to be a contract or an unactivated account |
amount | uint256 | The rent resource corresponding to the amount of TRX, the minimum unit, if the amount is not 0 (renewal only), it must be greater than 1 TRX |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
msg.value | New deposit of this time |
Returns: None, revert on failure.
Return resources (called by payer)
Return resources. Return resources in the order (msg.sender, receiver, resourceType). When the remaining deposit is insufficient, all resources will be forcibly emptied, and the remaining deposit will be returned to the order payer.
Parameter description:
Parameter | Type | Description |
---|---|---|
msg.sender | Order payer | |
receiver | address | Resource receiver |
amount | uint256 | The amount of TRX correspounding to the resources returned, the minimum unit |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
Returns: The amount of the deposit returned in this operation. 0 for a partial return.
Return resources (called by receiver)
Return resources. Return resources in the order (renter, msg.sender, resourceType). When the remaining deposit is insufficient, all resources will be forcibly emptied, and the remaining deposit will be returned to the order payer.
Parameter description:
Parameter | Type | Description |
---|---|---|
msg.sender | Resource receiver | |
renter | address | Order payer |
amount | uint256 | The amount of TRX correspounding to the resources returned, the minimum unit |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
Returns: The amount of the deposit returned in this operation. 0 for partial return.
Liquidate
When the order deposit is insufficient, the liquidator can liquidate the order, and the liquidator will get the liquidation reward. If there is any remaining deposit, it will be returned to the order payer.
Parameter description:
Parameter | Type | Description |
---|---|---|
msg.sender | Liquidator | |
renter | address | Order payer |
Receiver | address | Resource receiver |
resourceType | uint256 | Resource type, 0: bandwidth; 1: energy |
Returns: Liquidation reward in this operation.
Key Events
Event | Description |
---|---|
| Emits when renting occurs
|
| Emits when resources are returned
|
| Emits when liquidation occurs
|
Last updated