All EOS operations related to contract data storage require the purchase of RAM. The RAM transaction is through the built-in mechanism of EOS system. The core algorithm is based on the Bancor protocol, which means the price will go up when there are more people buy RAM and the price will go down when there are more people sell RAM.
There are 2 way to buy RAM in MathWallet:
1 The Resource Bar
This way is simple, you just pay EOS to buy the amount of RAM needed
2 The RAM Exchange
This way will give you more information about the latest RAM price and trend.