# Calculator endpoints (Decentraland strategy) #### /calculator/bulk-calculate ### Calculates energy consumptions for multiple countries. Returns total consume amount (volume) and consumption for regions and countries (value) in kWh ### Formula: There is fixed and individual amount. Fixed: generic amount that covering the server, infrastructure of Decentraland. Individual: Amount that is linked to a user and his/her location. This adds up to the fixed amount. ### Implementation: We calculate individual total amount (amount that is linked to a user and his/her location.) and multiply it by the mumber of people. Then we add fixed total amount to it to get total consume amount. Example payload: ```json [{ "people": 1, "date": "2022-08-03T07:37:04.945Z", "typeOfEnergy": "SOLAR", "country": "France" }, { "people": 1, "date": "2022-08-03T07:37:04.945Z", "typeOfEnergy": "SOLAR", "country": "Germany" }] ``` Response: ![](https://i.imgur.com/i6OPUZd.png) #### /calculator/issue-decentraland-event-ticket ### Creates Decentraland Event nft ticket Important note: All countries have to be loaded to the smart contract to test this endpoint. Otherwise issueNFTicketWithPayload() will throw an error saying "location is not valid" when creating an nft ticket if that country was not loaded. Example payload: ```json { "walletAddress": "0x030afB78C2625D9Ea09925FeE1E97038581Ff100", "description": "NRVerse-REC", "nftTicket": "bloXmove", "imageTemplateUrl": "https://picsum.photos/200", "ticketFormat": "TAILORED", "typeOfEnergy": "WIND", "participants": [ { "people": 1, "date": "2022-08-03T07:37:04.945Z", "typeOfEnergy": "WIND", "country": "France" } ] } ``` Response: ![](https://i.imgur.com/d1zncYv.png) # Calculator endpoints (Transaction strategy) We utilize https://github.com/kylemcdonald/ethereum-nft-activity to calculate energy consumption and some functionality from https://github.com/kylemcdonald/ethereum-emissions to determine countries. We use FeesOnlyModel which is described here: https://github.com/kylemcdonald/ethereum-nft-activity/blob/main/Per-Transaction%20Models.ipynb Important notes: 1. All countries have to be loaded to the smart contract to test ```/calculator/issue-ethereum-transaction-ticket``` endpoint. Otherwise issueNFTicketWithPayload() will throw an error saying "location is not valid" when creating an nft ticket if that country was not loaded. 2. It's not always possible to determine country or region where transaction was mined, therefore country and region can be "unknown". Currently, if we pass energyRequest with "unknown" region to issueNFTicketWithPayload(), there will be an error saying "location is not valid". #### /calculator/transactions ### Calculates energy consumption for ethereum transactions. Accepts networkId and array of transactions. Returns total consume amount (volume) and consumption for regions and countries (value) in kWh. Currently supported networks: mainnet, rinkeby Example payload: ```json { "transactions": [ "0xbbdf5e8ed969aab164c0b3cd2363613207b303081e9b2f915ef9345112779830" ], "networkId": 4 } ``` Response: ![](https://i.imgur.com/XFQMHzM.png) #### /calculator/issue-ethereum-transaction-ticket ### Creates ethereum transaction nft ticket Example payload: ```json { "networkId": 4, "transactions": [ "0xbbdf5e8ed969aab164c0b3cd2363613207b303081e9b2f915ef9345112779830", "0xbbdf5e8ed969aab164c0b3cd2363613207b303081e9b2f915ef9345112779830" ], "walletAddress": "0x030afB78C2625D9Ea09925FeE1E97038581Ff100", "description": "NRVerse-REC", "nftTicket": "bloXmove", "imageTemplateUrl": "https://picsum.photos/200", "ticketFormat": "TAILORED", "typeOfEnergy": "WIND" } ``` Response: ![](https://i.imgur.com/uFbL6xc.png)