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.

function rentals(
        address renter, 
        address receiver, 
        uint256 resourceType
    ) 
        public 
        view 
        returns (RentalInfo)

struct RentalInfo {
    uint256 amount;
    uint256 securityDeposit;
    uint256 rentIndex;
}

Parameter description:

Returns Values:


Query current rental order information (updated to current)

View the information of an order, with the returned data updated to current.

function getRentInfo(
        address renter,
        address receiver,
        uint256 resourceType
    )
        external
        view
        returns (uint256, uint256)

Parameter description:

Returns Values:

Write Interface

Rent resources

Rent resources, allow amount = 0 (extension only) or msg.value = 0 (no new deposit), both are 0 is not allowed.

function rentResource(
        address receiver,
        uint256 amount,
        uint256 resourceType
    )
        external
        payable

Parameter description:

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.

function returnResource(
        address receiver,
        uint256 amount,
        uint256 resourceType
    )
        external
        returns (uint256)

Parameter description:

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.

function returnResourceByReceiver(
        address renter,
        uint256 amount,
        uint256 resourceType
    )
        external
        returns (uint256)

Parameter description:

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.

function liquidate(
        address renter,
        address receiver,
        uint256 resourceType
    )
        external
        returns (uint256)

Parameter description:

Returns: Liquidation reward in this operation.

Key Events

Last updated