GNT vs W-GNT

A sub currency in ethereum is a contract that keeps track of balances and provides functions to move those balances around.

While its fine to have very different implementations of a currency like different monetary policy, fees, governance etc There is a standard way developers can write a contract that represents a token so that it can be used by other contracts such as exchanges so that the exchange contracts do not need to be re-written or deployed for every new token.

If a token contract has the standard set of functions that are expected then a contract only needs to know the address of the token to be able to interact with it.

GNT implements the standard functions balanceOf() and transfer() so other contracts can query the balance of an address and transfer GNT if they have a balance but GNT does not implement approve() and transferFrom().

This is thy GNT cannot be used directly by mkr.market and EtherDelta. These functions are used by those exchanges because when a transfer happens a token contract is not interacting with the recipient of the funds but instead simply updating its own internal balance. In other words a contract does not know when it has received some tokens or from what address unless it is told so. The way this is done with mkr.market and etherDelta is to first approve the contracts that are behind each exchange to be able to move funds on behalf of the user and then by telling the contracts how much they can transfer from what account. By doing things this way the exchange contracts are aware of receiving funds by virtue of the fact that they are caller of transferFrom().

It is of course possible to make a contract that can be used as an exchange that does not rely on approve and transferFrom. If you have a wallet that is owned by only one person then the contract does not need to know who sent it funds because it can assume that all funds it received are from its owner. This is how the contracts behind https://cryptoderivatives.market/ work and why it was used before any other platform to trade GNT. Each contract when it receives ETH will automatically send any GNT it has at its fixed price or return any change due. You can see the source for what that looks like.

W-GNT is a contract that acts like a token. To issue W-GNT you deposit 1 GNT to get 1 W-GNT and at any point you can withdraw 1-GNT for every W-GNT you have which burns the W-GNT. because every W-GNT is a claim to 1 GNT without any fees to convert between them besides gas the value of W-GNT is exactly that of GNT.

You cant just transfer GNT to the W-GNT contract to get some W-GNT though because it wouldn't know who to credit it to in its internal ledger. Instead you would call a function of the W-GNT contract to get a deposit address. This creates another contract that is only for allowing you to deposit GNT into so that it can be pulled out of it by the W-GNT contract and in so doing allows the correct amount of W-GNT to be credited to you and the correct amount of W-GNT to be available for withdrawal when needed.

Now even though you can treat W-GNT as if it is GNT, it is important to note that they are different contracts. When it comes time that you need GNT to interact with Golem in some way you will have to unwrap the GNT, that is withdraw it from the W-GNT contract.

The W in W-GNT stands for wrapper. The same goes for W-ETH which is wrapped Ether. A contract that holds either and acts like a token pegged 1 to 1 with it. The reason for wrapping ETH is so that exchanges don't have to have a different implementation for trading between ETH and an ERC20 Token compared to trading between 2 ERC20 tokens.

/r/GolemProject Thread