While the code of the $WXM token smart contract is not publicly available yet, it’s very close to being finalized. Here are some insights on its design and the decisions we’ve made.
Published in · 5 min read · Feb 28, 2023
--
WeatherXM stands at the intersection of Meteorology, Internet of Things (IoT) and Web3. This is the first article in a series that will present various Web3 aspects of the project, while explaining the fundamentals of Web3 to members of our community that don’t have a Web3 background.
For the purposes of this article, you can think of an ERC20 token as a two-column table together with some code that lives on the Ethereum blockchain: one column holds wallet addresses and the other one their token balances.
Each token implements its own table and functions, so there’s one for $UNI, one for $DAI, one for $AAVE and so on.
The contents of this table can usually be changed using the transferFrom function which is implemented by the code of the token smart contract:
transferFrom(from, to, amount) deducts an amount from one wallet and adds the amount to an other. It can only be called by the wallet that holds the amount (the “from” address).
According to the standard, an ERC20 smart contract has to implement some more functions such as balanceOf(), approve() and allowance() that are not important for the scope of this article.
Also, a token contract may have more functions to support functionality like minting new tokens, burning tokens, pausing/unpausing the contract, staking or do other exotic stuff. For example, some ERC20 tokens have an blacklist that blocks transfers to or from blacklisted addresses.
Most users do not check the source code of a token’s smart contract. They trust that auditors, the developer community and that other users with higher stakes than them have done a good job checking it. This is why most smart contracts make their source code available to the public.
However, it’s good to have in mind that:
- ERC20 tokens are not “in your wallet”. Your balance is kept in a smart contract that the creator of the token wrote and it’s governed by the rules implemented by the smart contract code. (This is why we call it a “contract”.)
- When you transfer ERC20 tokens, you (usually your wallet) just tell the token’s smart contract to reduce your balance and increase someone else’s balance.
- The reason why such a system can be trusted is that the smart contract “lives” on the blockchain which means that its rules will be followed to the letter and that they can not change (unless the smart contract has said so in advance, something known as upgradable contracts).
Now that we have an understanding of how ERC20 tokens work, let’s see how $WXM, the token of the WeatherXM Network was designed.
$WXM is programmed to have a maximum supply of 100,000,000 tokens. But it does not have a fixed supply: After reaching the 100,000,000 limit, if tokens are burned and the total supply drops, then new tokens can be minted again as long as the total supply does not exceed 100,000,000.
In addition to the standard ERC20 functions, like transferFrom() described above, there is a mint() function that creates new tokens, and a burn() function that burns tokens.
The mint() function was implemented with the following in mind:
- Anyone can call the mint() function at any time, but if it’s called more than once in a day, it will revert with an error. This means that while the WeatherXM company will make sure it’s called once daily, according to the schedule laid out in the Whitepaper, minting does not depend on the company.
- If mint() is not called for more than a day, then it can be called consecutive times. For example, if mint() has not been called for two days, mint() can be called three times and it will generate the tokens that corresponded to the “missed” days.
- As expected, mint() can not generate new tokens if the total supply of $WXM exceeds 100,000,000, in which case it will revert with an error.
- The $WXM contract is Ownable. There is an “owner” address that can pause/unpause the contract and also update the destination address where newly minted tokens are sent.
The destination of newly minted tokens will be an other smart contract that distributes them to station owners (rewards), the company, its investors, and the pools described in the Whitepaper.
No other special permissions are granted to the owner of the contract. Once the infrastructure has been tested and the WeatherXM ecosystem has matured, ownership of the contract can be transferred to the DAO or it can be renounced (after which point no one can use the “admin” functions).
The burn(amount) function can also be called by anyone. It will destroy the amount of tokens, provided that the caller has enough balance to do so. This is a very simple and “dumb” function and it will rarely be used on its own. It is intended to be used by the BurnPool contract that implements the burn mechanism as described in the Whitepaper (expect a separate article on this).
Finally, the $WXM smart contract is not upgradable, which means that the way it works cannot be changed by anyone.
The $WXM ERC20 contract is an ERC20 contract that has been kept simple on purpose because it is the foundation of the WeatherXM ecosystem and it will not be upgradable.
It ensures that new tokens are minted according to the schedule described in the Whitepaper and that the total supply does not exceed 100,000,000. It also allows minting of new tokens when the supply drops bellow 100,000,000 due to token burns.
The only special permissions granted to the contract owner are the ability to pause/unpause the contract and to change the destination address of the newly minted tokens. Ownership will eventually be renounced or transferred to a DAO.
WeatherXM is building the fastest growing global weather network in the world. You can learn more about the project at weatherxm.com.