# FriendTech Key Price Formula **Published by:** [2048.eth](https://paragraph.com/@2048-eth/) **Published on:** 2023-10-18 **URL:** https://paragraph.com/@2048-eth/friendtech-key-price-formula ## Content The first key price for a room of FriendTech is 0, The price of nth(n≥2) key is: 0.0000625 * ( n-1)² ETH 。 Contract code getPrice(uint256 supply, uint256 amount), means the money needs to pay to buy amount keys at the current supply.function getPrice(uint256 supply, uint256 amount) public pure returns (uint256) { uint256 sum1 = supply == 0 ? 0 : (supply - 1 )* (supply) * (2 * (supply - 1) + 1) / 6; uint256 sum2 = supply == 0 && amount == 1 ? 0 : (supply - 1 + amount) * (supply + amount) * (2 * (supply - 1 + amount) + 1) / 6; uint256 summation = sum2 - sum1; return summation * 1 ether / 16000; } Let’s simplify the code , get the total payment for buying amount keys when the supply is 0 :function getPrice2(uint256 amount) public pure returns (uint256) { uint256 sum2 = (amount - 1) * (amount) * (2 * ( amount- 1) + 1) / 6; uint256 summation = sum2; return summation * 1 ether / 16000; } getPrice2(amount) = (amount - 1) * (amount) * (2 * ( amount- 1) + 1) * 1 ether / 6 / 16000 getPrice2(amount)= (amount - 1) * (amount) * (2 * ( amount- 1) + 1) / 96000 ETH use n replace amount, remove the ETH unit and change the function name from getPrice2 to sum: sum(n) = (n - 1) * n * (2 * (n - 1) + 1) / 96000 sum(n) = (n² -n ) * (2n -1) / 96000 sum(n) = (2n³ - 3n² + n) / 96000 The payment for buying the key 1,2,3...n-2,n-1: sum(n-1) = (2(n-1)³ - 3(n-1)² + n-1) / 96000 sum(n-1) = (2n³ - 9n² + 13n - 6) / 96000 The price of the nth key price(n) = sum(n) - sum(n-1) price(n) = (2n³ - 3n²+ n) / 96000 - (2n³3 - 9n² + 13n -6) / 96000 price(n)= ((2n³ - 3n² + n) - (2n³ - 9n² + 13n -6)) / 96000 price(n) = ( 6n² - 12n +6) / 96000 price(n) = 6( n² - 2n +1) / 96000 price(n) = ( n² - 2n +1) / 16000 price(n) = ( n-1)² / 16000 price(n) = 0.0000625 * ( n-1)² ## Publication Information - [2048.eth](https://paragraph.com/@2048-eth/): Publication homepage - [All Posts](https://paragraph.com/@2048-eth/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@2048-eth): Subscribe to updates - [Twitter](https://twitter.com/en2048eth): Follow on Twitter