ERC20

The ERC20 mode uses an ERC20 token contract to facilitate the stress test. Each transaction in this mode involves an ERC20 token transfer between accounts using the contract's transfer method.

The ERC20 token being used in the stress test is called ZexCoin. This token is deployed on the blockchain network and is used to perform token transfers as part of the stress test.

ZexCoin.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

interface ERC20 {
    // Events
    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);

    // variables
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);

    function totalSupply() external view returns (uint256);
    function balanceOf(address _owner) external view returns (uint256 balance);
    function transfer(address _to, uint256 _value) external returns (bool success);
    function approve(address _owner, uint _ammount) external returns (bool success);
    function allowance(address _owner, address _delegate) external view returns (uint256 ammount);
    function transferFrom(address _from, address _to, uint _numTokens) external returns (bool success);
    
}

contract ZexCoinERC20 {

  event Transfer(address indexed from, address indexed to, uint tokens);
  event Approval(address indexed tokenOwner, address indexed spender, uint tokens);

    string public name;
    string public symbol;
    uint8 public decimals;

    mapping(address => uint256) balances;

    mapping(address => mapping (address => uint256)) allowed;

    uint256 totalSupply_;

    constructor(uint256 total, string memory coinName, string memory coinSymbol) {
      name = coinName;
      symbol = coinSymbol;
      decimals = 5;
      totalSupply_ = total;
      balances[msg.sender] = totalSupply_;
    }

    function totalSupply() public view returns (uint256) {
      return totalSupply_;
    }

    function balanceOf(address tokenOwner) public view returns (uint256 balance) {
        return balances[tokenOwner];
    }

    function transfer(address receiver, uint numTokens) public returns (bool) {
        require(
          numTokens <= balances[msg.sender],
          "The sender dosen't have enough funds to make the transfer!"
        );

        balances[msg.sender] -= numTokens;
        balances[receiver] += numTokens;
        emit Transfer(msg.sender, receiver, numTokens);
        return true;
    }

    function approve(address delegate, uint numTokens) public returns (bool) {
        allowed[msg.sender][delegate] = numTokens;
        emit Approval(msg.sender, delegate, numTokens);
        return true;
    }

    function allowance(address owner, address delegate) public view returns (uint) {
        return allowed[owner][delegate];
    }

    function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) {
        require(
          numTokens <= balances[owner],
          "The owner doesn't have enough funds to make the transfer!"
        );
        require(
          numTokens <= allowed[owner][msg.sender],
          "The delegate dosen't have enough allowance to make the transfer!"
        );

        balances[owner] -= numTokens;
        allowed[owner][msg.sender] -= numTokens;
        balances[buyer] += numTokens;
        emit Transfer(owner, buyer, numTokens);
        return true;
    }

    fallback () external payable {
        revert();
    }

    receive () external payable {
      revert();
    }
}

Last updated