Ich setze einen Crowdsale-Vertrag in Remix ein, aber egal wie hoch ich das Gaslimit setze (einmal auf 40000000 setze) oder wie stark ich das Wertfeld ändere, ich kann diesen Vertrag nicht dazu bringen, das Gaslimit nicht zu überschreiten. Der andere Vertrag, den ich bereitgestellt habe, war viel größer und wurde problemlos bereitgestellt, sodass ich denke, dass mit meinem Code etwas nicht stimmt. Hier ist es
pragma solidity ^0.4.19;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
/**
* @title Token
* @dev API interface for interacting with the BQPOT Token contract
*/
interface Token {
function transfer(address _to, uint256 _value) returns (bool);
function balanceOf(address _owner) constant returns (uint256 balance);
}
contract Crowdsale is Ownable {
using SafeMath for uint256;
Token token;
uint256 public constant RATE = 1000; //Tokens per Ether
uint256 public constant CAP = 73; //Cap in Ether
uint256 public constant START = 1517383764; //Must change for timestamp
uint256 public DAYS = 1; //Preorder lasts for 14 DAYS
bool public initialized = false;
uint256 public raisedAmount = 0;
// Who bought tokens and how many?
event BoughtTokens(address indexed to, uint256 value);
//Is the sale active?
modifier whenSaleIsActive() {
assert(isActive());
_;
}
//Pass in token contract address
function Crowdsale(address _tokenAddr){
require(_tokenAddr !=0);
token = Token(_tokenAddr);
}
//Makes sure there is correct amount of tokens sent to address
function initialize(uint256 numTokens) onlyOwner {
require(initialized == false);
require(tokensAvailable() ==numTokens); //Make sure tokens are available
initialized = true; //If they check out set initialize to true
}
function isActive() constant returns (bool) {
return (
initialized == true && //Is contract initialized?
now >= START && //To be active it must be after the start date
now <= START.add(DAYS * 1 days) && //Before end date
goalReached() == false //Also Goal is not yet reached
);
}
function goalReached() constant returns (bool) {
return (raisedAmount >= CAP * 1 ether);
}
function () payable {
buyTokens();
}
function buyTokens() payable whenSaleIsActive{
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(RATE);
BoughtTokens(msg.sender, tokens);
//Add to amount raised
raisedAmount = raisedAmount.add(msg.value);
//Send buyer tokens
token.transfer(msg.sender, tokens);
//Send ether to owner
owner.transfer(msg.value);
}
//Return number of tokens allocated to contract
function tokensAvailable() constant returns (uint256) {
return token.balanceOf(this);
}
//Stop contract and refund the owner
function destroy() onlyOwner {
//Send rest of tokens to the owner
uint256 balance = token.balanceOf(this);
assert(balance > 0);
token.transfer(owner, balance);
//Incase ether is left in contract
selfdestruct(owner);
}
}
Ich bin mir nicht sicher, aber könnte das sein:
Beachten Sie bei der Bereitstellung Ihrer Instanz die folgende Anweisung:
token = Token(_tokenAddr);
Token ist jedoch wie folgt definiert:
interface Token {
function transfer(address _to, uint256 _value) returns (bool);
function balanceOf(address _owner) constant returns (uint256 balance);
}
Ich würde hier zwei Punkte sehen:
Dies ist eine Schnittstelle, kein Vertrag und sollte daher nicht direkt als instanziierbar verwendet werden (es sollte verwendet werden, um einen anderen Vertrag zu gründen).
Auch wenn es keine Schnittstelle war, gibt es keinen Konstruktor und kein Ereignis mit Konstruktor, Sie sollten ein Argument im Signaturaufruf des Konstruktors angeben müssen, wenn Sie ein Argument bei der Bereitstellung übergeben.
Ich habe Ihren CrowdSale
Vertrag in Remix IDE mithilfe der Javascript-VM ohne Probleme bereitgestellt.
creation of Crowdsale pending...
[vm]from:0xca3...a733cto:Crowdsale.(constructor)value:0 wei data:0x608...77b3alogs:0hash:0x650...40b38
status 0x1 Transaction mined and execution succeed
transaction hash 0x65017f107f3c5309590ff765861ad0dd0f6bb2b6bee5c60bf99c5bdbe0340b38
contract address 0xbbf289d846208c16edc8474705c748aff07732db
from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c
to Crowdsale.(constructor)
gas 3000000 gas
transaction cost 941985 gas
execution cost 677381 gas
hash 0x65017f107f3c5309590ff765861ad0dd0f6bb2b6bee5c60bf99c5bdbe0340b38
input 0x608...77b3a
decoded input {
"address _tokenAddr": "0x692a70D2e424a56D2C6C27aA97D1a86395877b3A"
}
decoded output -
logs []
value 0 wei
Ich denke, ohne weitere Details darüber, wie Sie bereitstellen, z. B. Umgebung, andere Vertragsbereitstellung, gibt es keine Möglichkeit, dies weiter zu beheben.
Nanolucas
dunkelnächtlich
Nanolucas
dunkelnächtlich
Nanolucas
Ismael