⚡How to Inherit the NRG Smart Contract for seamless energy rental
Inheriting the NRG smart contract empowers you to establish your own energy system without providing the energy itself. You can not only obtain quotes and rent energy from within your customized contract but also have the freedom to set your own pricing structure. This can be used as the backbone for your system or as the foundation for a completely new setup.
Follow the steps below to implement the NRG smart contract in your project:
It's important to note the the NRG contract will send back any TRX refund in the event of a price change. Tron smart contracts must have fall back functions or it will fail to trigger the buy energy functions as its possible there could be a refund.
Step 1: Import the NRG Smart Contract Interface
First, you'll need to include the NRG smart contract's interface into your code. This will let you communicate and interact with the functionalities provided by the NRG contract.
Step 2: Create Your Smart Contract
You can now create your own smart contract that will inherit from the NRG interface. This allows you to leverage the energy rental and calculation methods provided by the NRG contract.
Step 3: Get a Quote and Rent Energy
Within your contract, you can call methods to calculate the rental price and actually rent the energy. This will enable you to set up your own system and pricing, utilizing the existing NRG energy supply.
Step 4: Customize as Needed
You can now extend the contract with your unique features, pricing structure, or additional functionalities. This could be tailored to your own energy system or to serve as the base for an entirely new application.
Full example
First, you'll need the interface for the NRG smart contract that allows for the calculation and rental of energy:
If you are applying energy to other users accounts you may consider joining the NRG affiliate program, which allows you to earn 5% commission from your sales. Get your ID and pass it into the call.
Now, you can create your own contract that inherits from this interface:
In this example,
MyEnergyContract
takes the address of an existing NRG smart contract and exposes methods to calculate the rental price (getQuote
) and rent energy (rentEnergy
). These methods can be integrated with your existing system and further customized as needed, providing the flexibility to add unique features or pricing structures.
If you require any further support of have questions you can always reach out to our team via our Telegram group
Last updated