CryptoFly.us | CRYPTOCURRENCY BITCOIN SHIRTS CLOTHING APPAREL HATS

CRYPTO NEWS

Solidity MINT ERC20

I will try to be brief in my doubt, below I am putting a model of a Smart Contract referring to a currency that I am creating for my game.

// SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0;  import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol";  contract SATOKCoin is ERC20, ERC20Burnable, Pausable, AccessControl, Ownable  {     using SafeMath for uint256;      bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");     bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");        constructor() ERC20("TOK COIN", "TOK") {         _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);         _setupRole(PAUSER_ROLE, msg.sender);         _mint(msg.sender, 100000 * 10 ** decimals());         _setupRole(MINTER_ROLE, msg.sender);                     }      function pause() public onlyRole(PAUSER_ROLE) {         _pause();     }      function unpause() public onlyRole(PAUSER_ROLE) {         _unpause();     }      function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {         _mint(to, amount);             }      function _beforeTokenTransfer(address from, address to, uint256 amount)         internal         whenNotPaused         override     {         super._beforeTokenTransfer(from, to, amount);     } } 

The currency will be used in a web game, and my doubts are as follows…

Player actions will result in rewards, these rewards will be "virtually" saved in my database (off-chain). At some point, the player will be able to redeem the values ​​he has, at that moment I need to transfer to him the value X of my token (code above), below the doubts.

first doubt

  • the easiest way is to use the "mint" option and thus mint new coins directly for the calling player (msg.sender)? Or
  • Use the "transfer" option, and thus transfer the value you have in the contract to the player’s wallet (msg.sender)?

second doubt Regarding security, how can I ensure that at the time of transferring the token the value that was passed in the function is the same one that the player has in my database (off-chain)? At this point I identified that there is Oracle, but I couldn’t find a way and I don’t know if there is a possibility of having a query in oracle before performing the transfer of the token to the player’s wallet, is this possible? and if it is possible someone could give me an example in practice of a code that would have?

Thanks for help.

Understanding the iquidus API settings

I am trying to understand what values I am being asked for in the settings.json to install the block explorer for Iquidus. I know how to get the genesis block as I have hard coded it when I did a fork to create a new altcoin, however, I am unsure how to get the genesis_tx.::Listen

I am trying to understand what values I am being asked for in the settings.json to install the block explorer for Iquidus. I know how to get the genesis block as I have hard coded it when I did a fork to create a new altcoin, however, I am unsure how to get the genesis_tx. I know you can convert it from the genesis block but I am unsure how?

“genesis”: { “genesis_tx”: ” “, “genesis_block”: ” “}

In terms of the API settings, they are asking for an address, blockindex, blockhash, and txhash. The blockindex can be any value within your block height… so do I pick just any one value for the index with the corresponding address in the transaction list? Also, how do I get the txhash and the blockhash? These values to my understanding are subject to change and I know they are stored in the blockchain… does anyone know how I can retrieve this information?

“api”: { “blockindex”: ” “, “blockhash”: ” “, “txhash”: ” “, “address”: ” ” },

I appreciate your time and consideration.

Crypto Hats, Crypto Shirts, Crypto Socks, Crypto Clothing

Solidity MINT ERC20

Shopping cart
There are no products in the cart!
Continue shopping
0