简体   繁体   English

“预期的主要表达式”错误 - 尝试在 remix 上编译智能合约 - ethereum ide

[英]"expected primary expression" error - Trying to compile a smart contract on remix - ethereum ide

I'm being honest this code is taken from a website that is supposed to ease the creation of a smart contract/token on the binance smart chain.老实说,此代码取自一个网站,该网站旨在简化在币安智能链上创建智能合约/令牌的过程。 (short backstory: Me and some friends thought it would be fun to have our own token to eg take bets, play poker whatsoever and are now trying to create our own through deploying our smart contract on the BSC) (简短的背景故事:我和一些朋友认为拥有我们自己的代币会很有趣,例如下注、玩扑克,现在正试图通过在 BSC 上部署我们的智能合约来创建我们自己的代币)

Here is a link to the template I used: https://github.com/binance-chain/bsc-genesis-contract/blob/master/contracts/bep20_template/BEP20Token.template这是我使用的模板的链接: https : //github.com/binance-chain/bsc-genesis-contract/blob/master/contracts/bep20_template/BEP20Token.template

I am trying to compile the code but in line 352 the error "expected primary expression" occurs.我正在尝试编译代码,但在第 352 行中出现“预期的主要表达式”错误。 What does that mean?这意味着什么? I am really just a layman.我真的只是一个外行。 The token is supposed to be called Omega and the Symbol OHM.该令牌应该被称为 Omega 和符号 OHM。

Thank you for your suggestions!谢谢你的建议!

The linked contract contains this function which causes the syntax error.链接的合约包含导致语法错误的函数。

constructor() public {
  _name = {{TOKEN_NAME}};
  _symbol = {{TOKEN_SYMBOL}};
  _decimals = {{DECIMALS}};
  _totalSupply = {{TOTAL_SUPPLY}};
  _balances[msg.sender] = _totalSupply;

  emit Transfer(address(0), msg.sender, _totalSupply);
}

I'm assuming that it was the contract author's intention to use these placeholders as a way to point out where you can fill in your own values.我假设合同作者有意使用这些占位符来指出您可以在哪里填写自己的值。

After you replace the placeholders with real values, the contract compiles successfully.用实际值替换占位符后,合约编译成功。

constructor() public {
  _name = "MyToken";
  _symbol = "MyT";
  _decimals = 18;
  _totalSupply = 1000000000000000000;
  _balances[msg.sender] = _totalSupply;

  emit Transfer(address(0), msg.sender, _totalSupply);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 remix.ethereum.org 上编译 bep-20.sol 问题 - Compile bep-20.sol Problem On remix.ethereum.org 尝试编译 Solidity 令牌合约但不断收到编译错误 - Trying to compile solidity token contract but keep getting compile error 错误:`>`标记之前的预期主表达式 - error: expected primary expression before `>` token 以太坊ERC20代币合约通过重新混合部署的合约地址添加到钱包时返回0.00代币余额 - Ethereum ERC20 Token contract returns 0.00 token balance when it added to wallet by remix deployed contract address 错误:类型合约 pSDATokenSale 不能隐式转换为预期类型合约 pSDA - Error: Type contract pSDATokenSale is not implicitly convertible to expected type contract pSDA 如何修复“之前的预期主表达式”'令牌'错误? - How do I fix a “Expected Primary-expression before ')' token” error? 智能合约执行费的决定因素 - Determinants of smart contract execution fee 如何将 ERC-721 智能合约与另一个智能合约连接起来 - How to connect a ERC-721 smart contract with another smart contract 如何在 Solidity 智能合约中启用 Claim Tokens? - How to enable Claim Tokens in Solidity Smart Contract? 标记“ /”上的语法错误,此标记后应为表达式 - Syntax error on token “/”, Expression expected after this token
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM