0

Please fix the error:

My Matic.sol:109:49: ParserError: Expected '{' but got end of source
function setBuyPrice(uint256 _newBuyPrice)
^

please fix the error in this code for me as i am having problem breaking my head trying to figure it out. please fix the error in this code for me as i am having problem breaking my head trying to figure it out. please fix the error in this code for me as i am having problem breaking my head trying to figure it out. please fix the error in this code for me as i am having problem breaking my head trying to figure it out. please fix the error in this code for me as i am having problem breaking my head trying to figure it out.




pragma solidity ^0.5.0;
import "https://github.com/maticnetwork/contracts/tree/master/wallet/mockups";
import "https://github.com/Arachnid/solidity-math/tree/0.5.0";
import "https://github.com/ethereum/go-ethereum/accounts/abi/bind";
import "https://github.com/ethereum/go-ethereum/common";
import "https://github.com/ethereum/go-ethereum/core/types";
import "https://github.com/ethereum/go-ethereum/crypto";

contract MaticTrader is ERC20, ERC20Detailed {
    
    string public standard = 'ERC20';
    string public name = 'Matic Token';
    string public symbol = 'MATIC';
    uint8 public decimals = 18;
    uint256 public totalSupply;
    
    uint256 public buyPrice;
    uint256 public sellPrice;
    uint256 public lastTradePrice;
    
    address public owner;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;

    
    constructor(
        uint256 _initialSupply,
        uint256 _buyPrice,
        uint256 _sellPrice,
        uint256 _lastTradePrice
    ) public {
        require(_initialSupply != 0);
        require(_buyPrice != 0);
        require(_sellPrice != 0);
        require(_lastTradePrice != 0);
        
        totalSupply = _initialSupply;
        balances[msg.sender] = _initialSupply;
        owner = msg.sender;
        
        buyPrice = _buyPrice;
        sellPrice = _sellPrice;
        lastTradePrice = _lastTradePrice;
    }
    
    function() external payable {}
    
    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];
    }
    
    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(balances[msg.sender] >= _value);
        require(allowed[msg.sender][_to] >= _value);
        
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value);
        return true;
    }
    
    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;
    }
    
    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];
    }
    
    function buyMatic(uint256 _value) public payable returns (bool success) {
        require(msg.value == _value * buyPrice);
        
        balances[msg.sender] += _value;
        totalSupply += _value;
        emit Transfer(0x0, msg.sender, _value);
        emit BuyMatic(msg.sender, _value, msg.value);
        return true;
    }
    
    function sellMatic(uint256 _value) public returns (bool success) {
        require(balances[msg.sender] >= _value);
        
        balances[msg.sender] -= _value;
        totalSupply -= _value;
        msg.sender.transfer(_value * sellPrice);
        emit Transfer(msg.sender, 0x0, _value);
        emit SellMatic(msg.sender, _value, msg.value);
        return true;
    }
    
    function tradeMatic(uint256 _sellAmount, uint256 _buyAmount) public returns (bool success) {
        require(balances[msg.sender] >= _sellAmount);
        
        balances[msg.sender] -= _sellAmount;
        msg.sender.transfer(_sellAmount * sellPrice);
        emit Transfer(msg.sender, 0x0, _sellAmount);
        emit SellMatic(msg.sender, _sellAmount, msg.value);
        
        balances[msg.sender] += _buyAmount;
        totalSupply += _buyAmount;
        emit Transfer(0x0, msg.sender, _buyAmount);
        emit BuyMatic(msg.sender, _buyAmount, msg.value);
        
        return true;
    }
    
    function setBuyPrice(uint256 _newBuyPrice)
  • 1
    First, look at the line of code indicated by the error. You'll see that something is wrong (incomplete). Second, repeating "fix my error" without showing proof that you tried to understand where the error comes from is a bit rude. – Gilles-Philippe Paillé Nov 09 '22 at 13:36
  • Your right. The problem is that I have the idea bit to learn solidity is very hard for someone with zero experience in coding like myself. To learn any programming is no easy task, but its no excuse though, im trying to learn as i am creating my first project or rather as a project is running. Perhaps this code is not unique but i dont know how to rectify the error. I admit, that it is rude but I used playground to create the code for me and now playground is not giving me the answer that I need "how to fix the error" . I'm sorry if I wasted your time. Can you assist with a link that can help. – Angelo Hendricks Nov 12 '22 at 08:22

0 Answers0