Wrapped INJ
What is a wrapped cryptocurrency?
On Injective, INJ is the cryptocurrency, which is what is used to pay from transaction fees on the network.
However, some dApps (including DEXes), only accept ERC20 tokens in their interfaces, and thus INJ does not work with them.
The solution is to create an ERC20 token which wraps INJ, called "wrapped INJ". Its token symbol is wINJ. Thus any dApp that accepts ERC20 tokens accepts wINJ.
The mechanism with which the wINJ token works is straightforward:
Increase the total supply (mint) whenever depositing INJ into it.
Decrease the total supply (burn) whenever withdrawing INJ from it.
You may think of wINJ as an ERC20 token that is 1-to-1 collateralised with INJ, and therefore be treated as equal value but with a different technical interface.
Is wINJ the same as wETH?
For those of you familiar with Ethereum, you may be thinking that this sounds the same as wrapper Ether (wETH). You are right, so far wINJ behaves in the same way as wETH.
However, note that the Injective network is designed with a MultiVM technical architecture. This means that if wINJ were to be implemented using a standard ERC20 implementation, as wETH does, wINJ would not be accessible when interacting with the the non-EVM parts of the Injective network (e.g. Cosmos transactions).
This is precisely the type of limitation that Injective's MultiVM Token Standard (MTS) was designed for.
Specifically, note this line:
contract WINJ9 is BankERC20, IWINJ9 {Instead of storing balances as uint256 values within the smart contract, as is typical of ERC20 implementations, the wINJ smart contract uses the Bank precompile. The magic happens in the _update function of BankERC20, where mint, burn, or transfer functions in the Bank precompile are invoked.
As those balances are stored/ retrieved from the Bank precompile, they are accessible from elsewhere within Injective's MultiVM architecture. For example, using the Cosmos SDK you can query the wINJ balances, even after updating them through EVM transactions; and vice versa. We refer to this as "native chain balances"/
Check out a full demo of wINJ in action.
How to use wINJ programmatically
Address on Injective Mainnet:
0x0000000088827d2d103ee2d9A6b781773AE03FfBAddress on Injective Testnet:
0x0000000088827d2d103ee2d9A6b781773AE03FfB
To convert INJ to wINJ, invoke the deposit function on this smart contract:
The function signature is:
deposit() public payableNote that you do not need to specify the amount as a parameter, instead set the
valueon the transactions, andpayablewill pick it up asmsg.value.
To convert wINJ to INJ, invoke the withdraw function on this smart contract:
The function signature is:
withdraw(uint256 wad) publicSet the amount of INJ you intend to received as the
wadparameter.
All other functions, e.g. transfers, are the same as standard ERC20.
How to use wINJ via the network explorer
Explorer URL for Injective Mainnet:
0x0000000088827d2d103ee2d9A6b781773AE03FfBExplorer URL for Injective Testnet:
0x0000000088827d2d103ee2d9A6b781773AE03FfB
To convert INJ to wINJ, invoke the deposit function on this smart contract:
Navigate to the "Contract" tab, then the "Read/Write contract" sub tab in the explorer page for the wINJ token.
Find the
deposit()function, and expand it by clicking on the>symbolFill in the field "Send native INJ (uint256)" with the amount of INJ you wish to convert
Note that this number is automatically multiplied by
10^18, you do not need to perform that conversion manually
Press the "Write" button
In your wallet, confirm the transaction to sign and submit it.
Your wallet should reflect an INJ decrease and a wINJ increase by the amount you selected.
Note that the INJ decrease will be marginally more, because it is used to pay for transaction fees.
To convert wINJ to INJ, invoke the withdraw function on this smart contract:
Navigate to the "Contract" tab, then the "Read/Write contract" sub tab in the explorer page for the wINJ token.
Find the
withdraw()function, and expand it by clicking on the>symbolFill in the field "wad (uint256)" with the amount of wINJ you wish to convert
Note that this number is automatically multiplied by
10^18, you do not need to perform that conversion manually
Press the "Write" button
In your wallet, confirm the transaction to sign and submit it.
Your wallet should reflect an INJ increase and a wINJ decrease by the amount you selected.
Note that the INJ increase will be marginally less, because it is used to pay for transaction fees.
Last updated