Wirklich neu bei Solidity, aber ich habe mich an diese Anleitung gehalten: https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6
Nur habe ich die neueste zeppelin-solidity
( 1.7.0
) verwendet, die laut diesem Commit die Token-Erstellung außerhalb des Crowdsale-Vertrags verschoben hat.
Wenn ich folgendes habe TestTokenCrowdsale.sol
:
pragma solidity ^0.4.18;
import "zeppelin-solidity/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "zeppelin-solidity/contracts/crowdsale/distribution/RefundableCrowdsale.sol";
import "zeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
/**
* @title SampleCrowdsaleToken
* @dev Very simple ERC20 Token that can be minted.
* It is meant to be used in a crowdsale contract.
*/
contract SampleCrowdsaleToken is MintableToken {
string public constant name = "Sample Crowdsale Token"; // solium-disable-line uppercase
string public constant symbol = "SCT"; // solium-disable-line uppercase
uint8 public constant decimals = 18; // solium-disable-line uppercase
}
/**
* @title SampleCrowdsale
* @dev This is an example of a fully fledged crowdsale.
* The way to add new features to a base crowdsale is by multiple inheritance.
* In this example we are providing following extensions:
* CappedCrowdsale - sets a max boundary for raised funds
* RefundableCrowdsale - set a min goal to be reached and returns funds if it's not met
*
* After adding multiple features it's good practice to run integration tests
* to ensure that subcontracts works together as intended.
*/
contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsale {
function SampleCrowdsale(uint256 _openingTime, uint256 _closingTime, uint256 _rate, address _wallet, uint256 _cap, MintableToken _token, uint256 _goal) public
Crowdsale(_rate, _wallet, _token)
CappedCrowdsale(_cap)
TimedCrowdsale(_openingTime, _closingTime)
RefundableCrowdsale(_goal)
{
//As goal needs to be met for a successful crowdsale
//the value needs to less or equal than a cap which is limit for accepted funds
require(_goal <= _cap);
}
}
Hier ist meine 2_deploy_contracts.js
:
const SampleCrowdsale = artifacts.require(“./TestTokenCrowdsale.sol”)
module.exports = function(deployer, network, accounts) {
const openingTime = Date.now()/1000|0 + 120;
const closingTime = openingTime + (3600 * 1 * 1); // *1 hour *1 days
const ethRate = new web3.BigNumber(100);
const wallet = accounts[0];
const cap = 100000000000000000000;
const goal = 200000000000000000000;
deployer.deploy(SampleCrowdsale, openingTime, closingTime, ethRate, wallet, cap, goal);
};
Beim Ausführen turffle migrate --reset
erhalte ich folgenden Fehler:
~/src/test-token $ truffle migrate --reset
Using network 'development'.
Running migration: 1_initial_migration.js
Replacing Migrations...
... 0x2e09c8647174d6fd5b26e2269d3d725b75d44881f27ad735323aca8fd19a517f
Migrations: 0xecfcab0a285d3380e488a39b4bb21e777f8a4eac
Saving successful migration to network...
... 0xd656595c57159a378d57439d8f0297d077c03ec39adfdac561dbfb8260758db3
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying SampleCrowdsale...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: SampleCrowdsale contract constructor expected 7 arguments, received 6
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:390:1
at new Promise (<anonymous>)
at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:374:1
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
Was vermisse ich?
Ihnen fehlt ein Konstruktorargument. Ihre MintableToken-Adresse, um genau zu sein.
Versuchen Sie zuerst, Ihren Token bereitzustellen, dann Ihren Crowdsale und geben Sie einfach die Adresse dieses Tokens ein
deployer.deploy(YourToken).then(function(){
deployer.deploy(SampleCrowdsale, openingTime, closingTime, ethRate, wallet, cap, YourToken.address, goal).then( async () => {
const instance = await OurCrowdsale.deployed();
const token = await instance.token.call();
console.log('Token Address', token);
});
});
Vas
Achala Dissanayake