0

Getting Error while working on solidity for TRC20 Token Cretaion

ParserError: Expected identifier but got 'contract'

CODE

pragma solidity ^0.8.4; MIT

contract TRC20 {
        
    string public name;
    string public symbol;
    unit8 public decimals = 8;
    unit256 public totalsupply;
    
    mapping (address => unit256) public balanc0f;
    mapping (address => mapping(address=>unit256)) public allowance;
    
    event Transfer(address indexed from, address indexed to, unit256 value);
    event Approval(address indexed _owner, address indexed _spender, unit256 value);
    event Burn(address indexed from, unit256 value);
2
  • Please post the code (at least the beginning of it) Commented Aug 4, 2021 at 8:47
  • contract TRC20 { string public name; string public symbol; unit8 public decimals = 8; unit256 public totalsupply; mapping (address => unit256) public balanc0f; mapping (address => mapping(address=>unit256)) public allowance; event Transfer(address indexed from, address indexed to, unit256 value); event Approval(address indexed _owner, address indexed _spender, unit256 value); event Burn(address indexed from, unit256 value);
    – user78709
    Commented Aug 4, 2021 at 9:53

2 Answers 2

1

You have an extra word "MIT" there. Just remove that.

If you want to indicate the contract's licensing mode, you can add something like this as the first line:

// SPDX-License-Identifier: MIT

Have a look here for the complete styling guide: https://docs.soliditylang.org/en/v0.8.0/style-guide.html

2
  • Now i am getting Error: unit8 public decimals = 18; DeclarationError: Identifier not found or not unique. --> TRC TEST.sol:8:5: | 8 | unit8 public decimals = 18;
    – user78709
    Commented Aug 5, 2021 at 8:46
  • it should be uint instead of unit. Please try to be more careful and try to solve the problems yourself first. If you have further questions, please post a new question Commented Aug 5, 2021 at 8:53
1

Remove MIT from pragma solidity ^0.8.4; MIT and add a closing bracket

3
  • If i remove MIT then i got another error Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see spdx.org for more information.
    – user78709
    Commented Aug 5, 2021 at 8:32
  • 7 | unit8 public decimals = 18; | ^^^^^ string public name; string public symbol; unit8 public decimals = 18; unit256 public totalsupply;
    – user78709
    Commented Aug 5, 2021 at 8:35
  • for the license part you can use : // SPDX-License-Identifier: MIT
    – Badr Bellaj
    Commented Aug 5, 2021 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.