zeppelinSales Contract Konstruktor hat 3 Argumente erwartet, 0 erhalten

Ich versuche, einen Crowdsale-Vertrag bereitzustellen, aber wenn ich "trufflemigrate --network ropsten" mache, erhalte ich diese Fehler:

Running migration: 1_initial_migration.js Deploying Migrations... ... 0xf8166f59ad6440ba56504956e5c54f7af17a30d6a6c64af6dd142808084e674d Migrations: 0x2be64f6a5ccb337d6106b343574eaa6a60b3f75d Saving successful migration to network... ... 0x6626bb628643554f06569c1a7b970b6d096242104b3ce711b69aff411530ab07 Saving artifacts... Running migration: 2_deploy_contracts.js Deploying zeppelinSales... Error encountered, bailing . Netzwerkstatus unbekannt. Überprüfen Sie erfolgreiche Transaktionen manuell. Fehler: zeppelinSales-Vertragskonstruktor erwartete 3 Argumente, erhielt 0 bei /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:390:1 bei new Promise () bei /usr/ local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:374:1 bei process._tickCallback (internal/process/next_tick.js:188:7)

Hier ist meine zeppelinSales.sol:

pragma solidity ^0.4.24;
import "zeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "zeppelin-solidity/contracts/math/SafeMath.sol";
import "zeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";


/**
 * @title Crowdsale
 * @dev Crowdsale is a base contract for managing a token crowdsale,
 * allowing investors to purchase tokens with ether. This contract     implements
 * such functionality in its most fundamental form and can be extended to provide additional
 * functionality and/or custom behavior.
 * The external interface represents the basic interface for purchasing tokens, and conform
 * the base architecture for crowdsales. They are *not* intended to be modified / overridden.
 * The internal interface conforms the extensible and modifiable surface of crowdsales. Override
 * the methods to add functionality. Consider using 'super' where appropriate to concatenate
 * behavior.
 */
contract zeppelinSales {
  using SafeMath for uint256;
  using SafeERC20 for ERC20;

  // The token being sold
  ERC20 public token;

  // Address where funds are collected
  address public wallet;

  // How many token units a buyer gets per wei.
  // The rate is the conversion between wei and the smallest and indivisible token unit.
  // So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK
  // 1 wei will give you 1 unit, or 0.001 TOK.
  uint256 public rate;

  // Amount of wei raised
  uint256 public weiRaised;

  /**
   * Event for token purchase logging
   * @param purchaser who paid for the tokens
   * @param beneficiary who got the tokens
   * @param value weis paid for purchase
   * @param amount amount of tokens purchased
   */
  event TokenPurchase(
    address indexed purchaser,
        address indexed beneficiary,
    uint256 value,
    uint256 amount
  );

  /**
   * @param _rate Number of token units a buyer gets per wei
   * @param _wallet Address where collected funds will be forwarded to
   * @param _token Address of the token being sold
   */
  constructor(uint256 _rate, address _wallet, ERC20 _token) public {
    require(_rate > 0);
    require(_wallet != address(0));
    require(_token != address(0));

    rate = 8 * (10**8);
    wallet = 0xF76075Cf3B674fB9656E393e9e17091B01243666;
    token = token = ERC20(0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf);
  }

  // -----------------------------------------
  // Crowdsale external interface
  // -----------------------------------------

  /**
   * @dev fallback function ***DO NOT OVERRIDE***
   */
  function () external payable {
    buyTokens(msg.sender);
  }

  /**
   * @dev low level token purchase ***DO NOT OVERRIDE***
   * @param _beneficiary Address performing the token purchase
   */
  function buyTokens(address _beneficiary) public payable {

    uint256 weiAmount = msg.value;
    _preValidatePurchase(_beneficiary, weiAmount);

    // calculate token amount to be created
    uint256 tokens = _getTokenAmount(weiAmount);

    // update state
    weiRaised = weiRaised.add(weiAmount);

    _processPurchase(_beneficiary, tokens);
    emit TokenPurchase(
      msg.sender,
      _beneficiary,
      weiAmount,
      tokens
    );

    _updatePurchasingState(_beneficiary, weiAmount);

    _forwardFunds();
    _postValidatePurchase(_beneficiary, weiAmount);
  }

  // -----------------------------------------
  // Internal interface (extensible)
  // -----------------------------------------

  /**
   * @dev Validation of an incoming purchase. Use require statements to     revert state when conditions are not met. Use `super` in contracts that     inherit from Crowdsale to extend their validations.
   * Example from CappedCrowdsale.sol's _preValidatePurchase method: 
   *   super._preValidatePurchase(_beneficiary, _weiAmount);
   *   require(weiRaised.add(_weiAmount) <= cap);
   * @param _beneficiary Address performing the token purchase
   * @param _weiAmount Value in wei involved in the purchase
   */
  function _preValidatePurchase(
    address _beneficiary,
    uint256 _weiAmount
  )
    internal
  {
    require(_beneficiary != address(0));
    require(_weiAmount != 0);
  }

  /**
   * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid conditions are not met.
   * @param _beneficiary Address performing the token purchase
   * @param _weiAmount Value in wei involved in the purchase
   */
  function _postValidatePurchase(
    address _beneficiary,
    uint256 _weiAmount
  )
    internal
  {
    // optional override
  }

  /**
   * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
   * @param _beneficiary Address performing the token purchase
   * @param _tokenAmount Number of tokens to be emitted
   */
  function _deliverTokens(
    address _beneficiary,
    uint256 _tokenAmount
  )
    internal
  {
    token.safeTransfer(_beneficiary, _tokenAmount);
  }

  /**
   * @dev Executed when a purchase has been validated and is ready to be executed. Not necessarily emits/sends tokens.
   * @param _beneficiary Address receiving the tokens
   * @param _tokenAmount Number of tokens to be purchased
   */
  function _processPurchase(
    address _beneficiary,
    uint256 _tokenAmount
  )
    internal
  {
    _deliverTokens(_beneficiary, _tokenAmount);
  }

  /**
   * @dev Override for extensions that require an internal state to check for validity (current user contributions, etc.)
   * @param _beneficiary Address receiving the tokens
   * @param _weiAmount Value in wei involved in the purchase
   */
  function _updatePurchasingState(
    address _beneficiary,
    uint256 _weiAmount
  )
    internal
  {
    // optional override
  }

  /**
   * @dev Override to extend the way in which ether is converted to tokens.
   * @param _weiAmount Value in wei to be converted into tokens
   * @return Number of tokens that can be purchased with the specified _weiAmount
   */
  function _getTokenAmount(uint256 _weiAmount)
    internal view returns (uint256)
  {
    return _weiAmount.mul(rate);
  }

  /**
   * @dev Determines how ETH is stored/forwarded on purchases.
   */
  function _forwardFunds() internal {
    wallet.transfer(msg.value);
  }
}

Und hier ist meine 2_deploy_contracts.js

    const zeppelinSales = artifacts.require("./zeppelinSales.sol");
    module.exports = function(deployer) {
      deployer.deploy(zeppelinSales);
    };

Hier ist die 1_initial_migration.js

    var Migrations = artifacts.require("./Migrations.sol");
    module.exports = function(deployer) {
      deployer.deploy(Migrations);
    };

Hier ist migrations.sol Pragma solidity ^0.4.23;

    contract Migrations {
      address public owner;
      uint public last_completed_migration;

      constructor() public {
        owner = msg.sender;
      }

      modifier restricted() {
        if (msg.sender == owner) _;
      }

      function setCompleted(uint completed) public restricted {
        last_completed_migration = completed;
      }

      function upgrade(address new_address) public restricted {
        Migrations upgraded = Migrations(new_address);
        upgraded.setCompleted(last_completed_migration);
      }
    }

Vielen Dank im Voraus!

Antworten (2)

Der Konstruktor von ZeppelinSalesbenötigt drei Parameter:

constructor(uint256 _rate, address _wallet, ERC20 _token) public

Aber Ihr Migrationsskript stellt sie nicht bereit:

const zeppelinSales = artifacts.require("./zeppelinSales.sol");
module.exports = function(deployer) {
    deployer.deploy(zeppelinSales);
};

Sie müssen die _rate, die _walletAdresse und die _tokenAdresse mit der deployer.deployFunktion angeben.

Ein Beispiel:

let rate = <INSERT THE RATE HERE>; // a number
let wallet = "<INSERT THE WALLET ADDRESS HERE>"; // an address string
let token = "<INSERT THE ERC20 TOKEN ADDRESS HERE>"; // an address string

const zeppelinSales = artifacts.require("./zeppelinSales.sol");
module.exports = function(deployer) {
    deployer.deploy(zeppelinSales, rate, wallet, token);
};
Henk, klingt nach einer großartigen Lösung, habe eine kurze Frage vor der Überprüfung - kann ich let rate = <8 * (10**8)> setzen; ?
und mein Token = ERC20 (0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf); like let token = "0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf"; ?
Sie können die Rate auf einstellen 8 * (10**8), also ohne <und >. Adressen können als Zeichenfolgen bereitgestellt werden

Wenn dies der Fall ist, können Sie die 3 nicht verwendeten Eingabeparameter im Konstruktor des Smart Contracts entfernen

Ändern:

  /**
   * @param _rate Number of token units a buyer gets per wei
   * @param _wallet Address where collected funds will be forwarded to
   * @param _token Address of the token being sold
   */
  constructor(uint256 _rate, address _wallet, ERC20 _token) public {
    require(_rate > 0);
    require(_wallet != address(0));
    require(_token != address(0));

    rate = 8 * (10**8);
    wallet = 0xF76075Cf3B674fB9656E393e9e17091B01243666;
    token = token = ERC20(0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf);
  }

Zu:

  constructor() public {    
    rate = 8 * (10**8);
    wallet = 0xF76075Cf3B674fB9656E393e9e17091B01243666;
    token = ERC20(0x0f26c1c05f1bbBC7Eff0488F1a98619e8a9758cf);
  }
Dang dann gibt es diese Fehler:
Dokumentierter Parameter "_rate" nicht in der Parameterliste der Funktion gefunden. ,DocstringParsingError: Dokumentierter Parameter "_wallet" nicht in der Parameterliste der Funktion gefunden. ,DocstringParsingError: Dokumentierter Parameter "_token" nicht in der Parameterliste der Funktion gefunden.
Es ist nur der Dokumentfehler, Sie können auch alle Kommentarcodes löschen ``` /** * @param _rate Anzahl der Token-Einheiten, die ein Käufer pro wei erhält * @param _wallet Adresse, an die gesammelte Gelder weitergeleitet werden * @param _token Adresse von das verkaufte Token */ ```
immer noch derselbe Fehler Fehler aufgetreten, Rettung. Netzwerkstatus unbekannt. Überprüfen Sie erfolgreiche Transaktionen manuell. Fehler: zeppelinSales-Vertragskonstruktor erwartete 3 Argumente, erhielt 0 bei /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:390:1 bei new Promise (<anonymous>) at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:374:1 at <anonymous> at process._tickCallback (intern/process/next_tick.js:188:7) Islams-MacBook-Air:publicsales talapbayev$
Ich denke, dass Sie den neuen Quellcode nicht gespeichert haben :)
Ich habe meine Antwort aktualisiert, PTAL;)
Ich habe bereits beide ausprobiert, ich denke, Henks Antwort wird funktionieren
Ja, Henks Antwort funktioniert auch, falls Sie die 3 Eingabeparameter beibehalten möchten. Meine Antwort, falls Sie einen Hardcode-Wert für die drei haben und sicher sind, dass das auch funktioniert :)
Richtig. @Josephhh In Ihrem Smart Contract werden die Eingabeparameter überschrieben. Sie können sie also genauso gut entfernen, wie diese Antwort beschreibt