1inch introduces Chi Gastoken
The 1inch team has launched Chi, a next-generation Gastoken that allows users to significantly save on gas.
The name of our project, 1inch, was inspired by Bruce Lee’s legendary “1inch punch”, an epitome of efficiency in Martial Arts, and aims to symbolize our efficiency in the crypto industry.
To execute a 1inch punch, you need power, in Asian Martial Arts it is called as Chi / Qi, whose equivalent in the crypto space is our new Chi Gastoken. Now, any user can burn their Chi tokens and thereby save on gas.
What is a Gastoken?
Every transaction on the Ethereum network requires some gas. A Gastoken facilitates transactions with the same amount of work but less gas. A Gastoken takes advantage of the Ethereum storage refund, see Ethereum Yellow Paper. To encourage smart contracts to erase unnecessary storage, Ethereum provides a refund for each zeroed element. So, in the process of burning, a Gastoken’s smart contract erases storage that were filled during minting. The most efficient storage gas refunds are achieved by creating and destroying sub smart contract, not by direct writes and erases of the storage.
The idea for the Chi token is based on the original Gastoken GST2 implementation. We saw that there were ways to improve the efficiency with:
- Reducing the smart contract address size by mining a private key with Profanity address generator, which allowed us to decrease size of the sub smart contracts by 1 byte.
- Using CREATE2 instruction to deploy sub smart contracts for their efficient address discovery during burning process.
- Fixing ERC20 incompatibilities of GST2
How much is Chi better than GST2?
The Chi token is 1% more optimized for minting, and 10% more efficient for burning.
y = 15000 * x / (20065 + 5065 * x) // GST1
y = 24000 * x / (35974 + 6689 * x) // GST2
y = 24000 * x / (35678 + 6053 * x) // CHI
How Chi can be used?
The deployment of a Ethereum smart contract requires substantial gas, and it could cost you for example between $5 and $10 per million of gas, while regular smart contract could have size of several millions of gas. But burning Chi tokens in the same transaction would reduce these costs by almost the half.
We have built on ETHGlobal HackMoney Online Hackathon such a tool called Deployer.eth.
The support of Chi token can be integrated in any smart contract with just a few lines of code by using following modifier:
modifier discountCHI {
uint256 gasStart = gasleft();
_;
uint256 gasSpent = 21000 + gasStart — gasleft() + 16 *
msg.data.length;
chi.freeFromUpTo(msg.sender, (gasSpent + 14154) / 41947);
}
In this case, Chi tokens will be burned from the caller’s wallet (Chi tokens should be approved to the contract by the user).
In case of burning Chi tokens from the contract itself (rather than from a user’s wallet), you need to change `msg.sender` in the ` chi.freeFromUpTo` function to `address(this)`. And don’t forget to top up your contract with Chi tokens.
How can you mint Chi tokens?
You can mint Chi tokens directly on Etherscan. Another option is the Chi Minter on 1inch. To use it, you need to deactivate all exchanges, except for the Chi minter.
The maximum minting limit is 140 Chi tokens, which, in turn, is explained by the block limit. We deliberately use about one half of the block, so that miners won’t reject this type of transaction, which is less profitable for them.
If, for instance, you swap 1 ETH using Chi Minter, you get 140 Chi tokens and pay 20 GWEI for gas. But we won’t spend the entire 1 ETH as the minting of 140 Chi tokens doesn’t cost that much. Only what is actually spent will be spent:
5,125,271 gas x 20 GWEI = 5125271*20*1e9/1e18 = 0.10250542 ETH
So, only about 0.1 ETH will be spent, rather than 1 ETH.
One other thing. When you mint Chi tokens and indicate a low gas price, your wallet will be blocked. Therefore, we advise that you use a separate wallet specifically for minting Chi tokens.
How can you trade Chi Gastoken
It is also possible to trade Chi token on 1inch. For that you need to select Chi in the from token drop down and a token you wish to get in the to token dropdown. 1inch find the best place where to sell your Chi token.
Very important to understand for everyone:
Imagine Chi token as tokenized version of actual gas price on Ethereum. Means if the gas price grow. Chi token price also grow. If gas price in Ethereum drops, the same would also happen with Chi.
Of course you can set a limit order on 1inch with the rate you wish.
How to deploy a smart contract with less gas costs?
You need to approve the Chi token to deployer.eth. To do that, go to the Write Contract section on Chi. Find the approve function and trigger it with the deployer.eth address and approval amount.
Click on the Deploy button on remix.ide and copy data to deploy (0x6080604…). Don’t click on confirm.
Go to the Write Contract section on the deployer.eth contract and paste the deploy data to chiDeploy for Chi burning. Click Write and confirm the transaction in the popup MetaMask window.
Here we are! Only 51.18% of gas was used and 6 Chi tokens were burned.
Finally, go to the Internal Transactions section. There, you can find the deployed contract address. Just find create_0 below the Type Trace Address. In this line, below the To column you can see the deployed contract address.
Now go ahead and check out Chi for yourself!
Deployer.eth: https://etherscan.io/address/deployer.eth
Chi Gastoken on Etherscan: https://etherscan.io/token/0x0000000000004946c0e9F43F4Dee607b0eF1fA1c
Chi Gastoken repository: https://github.com/CryptoManiacsZone/chi
Chi Minter on 1inch: https://1inch.exchange/#/ETH/CHI
Subscribe to our Twitter account and Telegram channel!