These are chat archives for ethereum/tutorials

15th
Feb 2018
yononabike
@yononabike
Feb 15 2018 01:36
anyone recommend a service to create an alt-coin under Ethereum as a service?
sportandy
@sportandy
Feb 15 2018 03:53
Hey all, keen to get some advice on how to properly manage releasing coin over a number mints. We want to keep initial supply low and 1M and then create another 1M at 98% of coin sales, then 2M and so on. Any ideas on how best to approach this?
RaitzeR
@RaitzeR
Feb 15 2018 06:34
@sportandy Just either write the logic in the token contract, or write a basic escrow contract to hold the tokens until x happens
Markus Streicher
@mstreicher
Feb 15 2018 07:19
this dose not work!
the ethereum crowdsale is not woring
working
RaitzeR
@RaitzeR
Feb 15 2018 07:20
@mstreicher you mean my approach doesn't work, or are you replying to something else?
Markus Streicher
@mstreicher
Feb 15 2018 07:21
no i test the crowdsale and any function return 0 or ox
i cant get any withdraw and the safe withdraw dosent work too
all hangs in the contract
@RaitzeR do you know a solution?
RaitzeR
@RaitzeR
Feb 15 2018 07:24
where did you deploy it?
the main net?
or the main chain I mean
Markus Streicher
@mstreicher
Feb 15 2018 07:26
@RaitzeR yes on the main to test it in a live environment
RaitzeR
@RaitzeR
Feb 15 2018 07:27
@mstreicher and you succesfully tested it in a test chain like rinkeby or local?
Markus Streicher
@mstreicher
Feb 15 2018 07:28
@RaitzeR no because i cant mine eth there and the free 3 ETH link dosent work
just at the main tested
RaitzeR
@RaitzeR
Feb 15 2018 07:29
@mstreicher all of the functions require the crowdsale to be finished before you can call the functions. It will throw on all calls before the deadline has passed. Are you maybe encountering this error?
(if you're using the boilerplate crowdsale contract)
Markus Streicher
@mstreicher
Feb 15 2018 07:30
this is the contract: 0xdb93D1478e45D5B7F5A4845DFD492e82c575657a
@RaitzeR i dont know
when i try to call checkGoalReached i got 0
but then it should be able to safeWidthdarw or not?
RaitzeR
@RaitzeR
Feb 15 2018 07:32
are you familiar with solidity modifiers?
Markus Streicher
@mstreicher
Feb 15 2018 07:32
no
i am a javascript man

i can post my code:

pragma solidity ^0.4.16;

interface token {
function transfer(address receiver, uint amount) public;
}

contract Crowdsale {
address public beneficiary;
uint public fundingGoal;
uint public amountRaised;
uint public deadline;
uint public price;
token public tokenReward;
mapping(address => uint256) public balanceOf;
bool fundingGoalReached = false;
bool crowdsaleClosed = false;

event GoalReached(address recipient, uint totalAmountRaised);
event FundTransfer(address backer, uint amount, bool isContribution);

/**
 * Constrctor function
 *
 * Setup the owner
 */
function Crowdsale(
    address ifSuccessfulSendTo,
    uint fundingGoalInEthers,
    uint durationInMinutes,
    uint etherCostOfEachToken,
    address addressOfTokenUsedAsReward
) internal 
{
    beneficiary = ifSuccessfulSendTo;
    fundingGoal = fundingGoalInEthers * 1 ether;
    deadline = now + durationInMinutes * 1 minutes;
    price = etherCostOfEachToken * 0.0002 ether;
    tokenReward = token(addressOfTokenUsedAsReward);
}

/**
 * Fallback function
 *
 * The function without name is the default function that is called whenever anyone sends funds to a contract
 */
function () payable public 
{
    require(!crowdsaleClosed);
    uint amount = msg.value;
    balanceOf[msg.sender] += amount;
    amountRaised += amount;
    tokenReward.transfer(msg.sender, amount / price);
    FundTransfer(msg.sender, amount, true);
}

modifier afterDeadline() { if (now >= deadline) _; 
}

/**
 * Check if goal was reached
 *
 * Checks if the goal or time limit has been reached and ends the campaign
 */
function checkGoalReached() afterDeadline public 
{
    if (amountRaised >= fundingGoal){
        fundingGoalReached = true;
        GoalReached(beneficiary, amountRaised);
    }
    crowdsaleClosed = true;
}


/**
 * Withdraw the funds
 *
 * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
 * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
 * the amount they contributed.
 */
function safeWithdrawal() afterDeadline public 
{
    if (!fundingGoalReached) {
        uint amount = balanceOf[msg.sender];
        balanceOf[msg.sender] = 0;
        if (amount > 0) {
            if (msg.sender.send(amount)) {
                FundTransfer(msg.sender, amount, false);
            } else {
                balanceOf[msg.sender] = amount;
            }
        }
    }

    if (fundingGoalReached && beneficiary == msg.sender) {
        if (beneficiary.send(amountRaised)) {
            FundTransfer(beneficiary, amountRaised, false);
        } else {
            //If we fail to send the funds to beneficiary, unlock funders balance
            fundingGoalReached = false;
        }
    }
}

}

RaitzeR
@RaitzeR
Feb 15 2018 07:34
solidity modifiers ensure that you cannot call a function until a condition is met. The crowdsale contract has a modifier:
modifier afterDeadline() { if (now >= deadline) _; }
This means that you cannot call the checkGoalReached until the deadline is over
it will throw
Markus Streicher
@mstreicher
Feb 15 2018 07:35
But i added just 5 minutes for the sale
RaitzeR
@RaitzeR
Feb 15 2018 07:35
so when you created the contract, you set the deadline to be some arbitrary time in the future, you cannot call any of the functions (except the fallback function) until the deadline has been crossed
ok hmm
and when did you publish the code in the chain?
RaitzeR
@RaitzeR
Feb 15 2018 07:40
can you paste me the contract abi?
what did you put as a funding goal?
Markus Streicher
@mstreicher
Feb 15 2018 07:41
@RaitzeR fundingGoal = fundingGoalInEthers * 1 ether;
abi comes
RaitzeR
@RaitzeR
Feb 15 2018 07:42
no I mean when you created the contract what did you set it as?
Markus Streicher
@mstreicher
Feb 15 2018 07:42
[ { "constant": false, "inputs": [], "name": "checkGoalReached", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "deadline", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "beneficiary", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "tokenReward", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "fundingGoal", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "amountRaised", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "price", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "safeWithdrawal", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "name": "ifSuccessfulSendTo", "type": "address" }, { "name": "fundingGoalInEthers", "type": "uint256" }, { "name": "durationInMinutes", "type": "uint256" }, { "name": "etherCostOfEachToken", "type": "uint256" }, { "name": "addressOfTokenUsedAsReward", "type": "address" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "recipient", "type": "address" }, { "indexed": false, "name": "totalAmountRaised", "type": "uint256" } ], "name": "GoalReached", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "backer", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "isContribution", "type": "bool" } ], "name": "FundTransfer", "type": "event" } ]
0.0002 ETH was the fundinggoal
i created it 12 hours ago
Markus Streicher
@mstreicher
Feb 15 2018 07:52
@RaitzeR can you help me?
RaitzeR
@RaitzeR
Feb 15 2018 07:52
yeah just a sec :)
Markus Streicher
@mstreicher
Feb 15 2018 07:53
cool thx :smile:
RaitzeR
@RaitzeR
Feb 15 2018 08:15
@mstreicher you're positive this is the correct ABI?
can't seem to access it properly
Markus Streicher
@mstreicher
Feb 15 2018 08:17
yes
but first i deplyed and after that i past the code into this: http://chriseth.github.io/browser-solidity/#version=soljson-latest.js and got the abi from there
thats the interface
Markus Streicher
@mstreicher
Feb 15 2018 08:24
[{"constant":false,"inputs":[],"name":"checkGoalReached","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"deadline","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenReward","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fundingGoal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"amountRaised","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"price","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"safeWithdrawal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"ifSuccessfulSendTo","type":"address"},{"name":"fundingGoalInEthers","type":"uint256"},{"name":"durationInMinutes","type":"uint256"},{"name":"etherCostOfEachToken","type":"uint256"},{"name":"addressOfTokenUsedAsReward","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"recipient","type":"address"},{"indexed":false,"name":"totalAmountRaised","type":"uint256"}],"name":"GoalReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"backer","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"isContribution","type":"bool"}],"name":"FundTransfer","type":"event"}]
@RaitzeR this one?
RaitzeR
@RaitzeR
Feb 15 2018 08:38
ok @mstreicher I think you didn't provide enough gas when you sent the contract
trying to get the code of the contract it returns 0x, which means that there is no code in that address.
Markus Streicher
@mstreicher
Feb 15 2018 08:39
how much gas i needed for such a contract?
@RaitzeR but you thik it should work?
RaitzeR
@RaitzeR
Feb 15 2018 08:40
yeah it should work. Well the gas amounts are a bit of a mystery to me honestly. How did you deploy the contract?
Markus Streicher
@mstreicher
Feb 15 2018 08:41
but with not enough gas it shount success or not?
over my ehter wallet on mac
RaitzeR
@RaitzeR
Feb 15 2018 08:41
btw you should really use remix.solidity.com to test out the code before deploying to the actual network. There's an in-memory blockchain you can use in the remix, so you can immediately test all the functions and what not
the transaction can be succesful even if you don't provide enough gas
if the transaction is succesful, it means that it was mined, but if there's not enough gas to compute the initializer, the code execution will fail
there's two different parts: transaction cost and execution cost
Markus Streicher
@mstreicher
Feb 15 2018 08:43
and put gas 50% of the range field
RaitzeR
@RaitzeR
Feb 15 2018 08:44
via remix.solidity.com you can see rough numbers for these
Markus Streicher
@mstreicher
Feb 15 2018 08:45
so i had to send more ethers to the contract
?
RaitzeR
@RaitzeR
Feb 15 2018 08:45
no
ok so if you send ether to the contract, it means that the contract holds this ether, but that has nothing to do with gas
it just means that this contract now has ether like any other address. But when you create the contract, you can create it with 0 ether, but you will have to specify the gas limits
Markus Streicher
@mstreicher
Feb 15 2018 08:47
so then i had to send the 100% of that range field
RaitzeR
@RaitzeR
Feb 15 2018 08:47
when you create this ethereum crowdsale contract, don't send any ether to it. If you use the Ethereum Wallet, just let it handle the gas limit
yeah
to test the code out
I tried it and seemed to be working
but sitll
still*
Markus Streicher
@mstreicher
Feb 15 2018 08:49
ok and i have to change the public functions to external?
RaitzeR
@RaitzeR
Feb 15 2018 08:49
there is also a possibility you just have a syntax error or something in your code, so make sure you test it out in remix and afterwards push with the Ethereum Wallet or whatever
Markus Streicher
@mstreicher
Feb 15 2018 08:49
it say it to me
RaitzeR
@RaitzeR
Feb 15 2018 08:49
hmm what
no you shouldn't need to change the visibility
actually it needs to stay public because people need to be able to interact with it
Markus Streicher
@mstreicher
Feb 15 2018 08:50
browser/ballot.sol:5:5: Warning: Functions in interfaces should be declared external.
function transfer(address receiver, uint amount) public;
^------------------------------------------------------^
RaitzeR
@RaitzeR
Feb 15 2018 08:53
aaa right in the interface
that's most probably just a warning thow, not an error
hmm I just figured out that your contract doesn't adhere to the interface at all
you never specified the transfer function in your contract
where did you get that interface from? It's not from the official boilerplate
that might also be a reason why the contract didn't initialize properly
Markus Streicher
@mstreicher
Feb 15 2018 08:56
yes thats from there:https://www.ethereum.org/crowdsale
Markus Streicher
@mstreicher
Feb 15 2018 09:02
isnt this the transfer function? tokenReward.transfer(msg.sender, amount / price * 6/5);
i created all on this tutorial -> ttps://www.ethereum.org/crowdsale
also the token
RaitzeR
@RaitzeR
Feb 15 2018 09:23
@mstreicher ok I went through your code and your initializer method is internal
function Crowdsale(
address ifSuccessfulSendTo,
uint fundingGoalInEthers,
uint durationInMinutes,
uint etherCostOfEachToken,
address addressOfTokenUsedAsReward
) internal
{
beneficiary = ifSuccessfulSendTo;
fundingGoal = fundingGoalInEthers 1 ether;
deadline = now + durationInMinutes
1 minutes;
price = etherCostOfEachToken * 0.0002 ether;
tokenReward = token(addressOfTokenUsedAsReward);
}
take the internal keyword off
function Crowdsale(
        address ifSuccessfulSendTo,
        uint fundingGoalInEthers,
        uint durationInMinutes,
        uint etherCostOfEachToken,
        address addressOfTokenUsedAsReward
    ) 
    {
        beneficiary = ifSuccessfulSendTo;
        fundingGoal = fundingGoalInEthers * 1 ether;
        deadline = now + durationInMinutes * 1 minutes;
        price = etherCostOfEachToken * 0.0002 ether;
        tokenReward = token(addressOfTokenUsedAsReward);
    }
that's the correct init function
Markus Streicher
@mstreicher
Feb 15 2018 09:24
then it throws No visibility specified. Defaulting to "public".
function Crowdsale(
^
Spanning multiple lines
RaitzeR
@RaitzeR
Feb 15 2018 09:24
instead of internal, put public
but that's not an error, it's just a warning
saying that if there's no visibility it will default to public
Markus Streicher
@mstreicher
Feb 15 2018 09:25
ok and then it will work correctly now?
but when i let it blank i cant execute the contract
RaitzeR
@RaitzeR
Feb 15 2018 09:36
that's weird
works fine on my end
but you can just put public
better that way
Markus Streicher
@mstreicher
Feb 15 2018 09:36
ok i will try
RaitzeR
@RaitzeR
Feb 15 2018 09:37
if you can run it in remix then it should work in the main net
Markus Streicher
@mstreicher
Feb 15 2018 09:40
one more question... the other ether and tokens in the salecontract are lost?
RaitzeR
@RaitzeR
Feb 15 2018 09:42
sadly, yes :/
on contract creation you shouldn't send any ether to it, unless there's a good reason for it
Markus Streicher
@mstreicher
Feb 15 2018 09:43
i looks like it worked
many thx to you
RaitzeR
@RaitzeR
Feb 15 2018 09:43
you're welcome
Markus Streicher
@mstreicher
Feb 15 2018 09:44
you can send me your token address and i will give you a little reward of my token :smile:
RaitzeR
@RaitzeR
Feb 15 2018 09:44
as a note, if you check the address in etherscan and click "Contract Code" tab, if it says 0x that means it wasn't executed properly for whatever reason
https://etherscan.io/address/0xdb93D1478e45D5B7F5A4845DFD492e82c575657a#code for example here you can see the 0x in your old contract
sure you can send some tokens to 0xF297dB33d48b3462576a086Ab9De28e7f7E20100 if you want :D
Markus Streicher
@mstreicher
Feb 15 2018 09:50
@RaitzeR and when deadline is reached i call safeWidthdrwal to get ethers and send the rewadr to investors?
RaitzeR
@RaitzeR
Feb 15 2018 09:56
@mstreicher mm.. Seems like the investors will get the rewards regardless. It transfers the rewards when they make a deposit, but nowhere in the code it retracts them
but anyways first you need to call "checkGoalReached()" before you can get the money from safeWithdrawal()
Markus Streicher
@mstreicher
Feb 15 2018 09:58
i tried it and i get 0.00000001 token instead of 1. whats the problem?
sorry for asking you so much
RaitzeR
@RaitzeR
Feb 15 2018 09:59
it's fine
just a sec
you modified the initializers price setter.
price = etherCostOfEachToken * 0.0002 ether;
that should be
price = etherCostOfEachToken * 1 ether;
and then in the init you should have it as whatever
so if you create the contract with ethercost of 0.001, then for every 0.001 ether an investor sends they will receive 1 token
Markus Streicher
@mstreicher
Feb 15 2018 10:01
but the price should be 0.0002 ether for 1 token
RaitzeR
@RaitzeR
Feb 15 2018 10:03
what did you input as parameters when you created the contract?
Markus Streicher
@mstreicher
Feb 15 2018 10:03
1
because i cant set the param 0.0002
i theows an error
RaitzeR
@RaitzeR
Feb 15 2018 10:03
ah
Markus Streicher
@mstreicher
Feb 15 2018 10:04
that is the reason why i do this
RaitzeR
@RaitzeR
Feb 15 2018 10:04
ok so when you got the 0.0000001 token how much money did you send to it?
0.0002?
Markus Streicher
@mstreicher
Feb 15 2018 10:04
yes
RaitzeR
@RaitzeR
Feb 15 2018 10:04
can you give me the new address of the contract?
Markus Streicher
@mstreicher
Feb 15 2018 10:05
0x7c8F1Ab60Af58dB9D1d1E2eDbb8b781f17AB52a9
and i added a 20% bonus
RaitzeR
@RaitzeR
Feb 15 2018 10:05
can you also give me the new abi
Markus Streicher
@mstreicher
Feb 15 2018 10:06
here tokenReward.transfer(msg.sender, amount / price * 6/5);
[ { "constant": false, "inputs": [], "name": "checkGoalReached", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "deadline", "outputs": [ { "name": "", "type": "uint256", "value": "1518687990" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "beneficiary", "outputs": [ { "name": "", "type": "address", "value": "0xa192da050bd3a66049411131fa719f1e524f6029" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "tokenReward", "outputs": [ { "name": "", "type": "address", "value": "0xe64683b29bc6b35d2879603fd20113be35417552" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "fundingGoal", "outputs": [ { "name": "", "type": "uint256", "value": "200000000000000" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "amountRaised", "outputs": [ { "name": "", "type": "uint256", "value": "200000000000000" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "price", "outputs": [ { "name": "", "type": "uint256", "value": "200000000000000" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "safeWithdrawal", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "name": "ifSuccessfulSendTo", "type": "address", "index": 0, "typeShort": "address", "bits": "", "displayName": "if Successful Send To", "template": "elements_input_address", "value": "" }, { "name": "fundingGoalInEthers", "type": "uint256", "index": 1, "typeShort": "uint", "bits": "256", "displayName": "funding Goal In Ethers", "template": "elements_input_uint", "value": "" }, { "name": "durationInMinutes", "type": "uint256", "index": 2, "typeShort": "uint", "bits": "256", "displayName": "duration In Minutes", "template": "elements_input_uint", "value": "" }, { "name": "etherCostOfEachToken", "type": "uint256", "index": 3, "typeShort": "uint", "bits": "256", "displayName": "ether Cost Of Each Token", "template": "elements_input_uint", "value": "" }, { "name": "addressOfTokenUsedAsReward", "type": "address", "index": 4, "typeShort": "address", "bits": "", "displayName": "address Of Token Used As Reward", "template": "elements_input_address", "value": "0xe64683b29bc6B35D2879603FD20113bE35417552" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "recipient", "type": "address" }, { "indexed": false, "name": "totalAmountRaised", "type": "uint256" } ], "name": "GoalReached", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "backer", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "isContribution", "type": "bool" } ], "name": "FundTransfer", "type": "event" } ]
RaitzeR
@RaitzeR
Feb 15 2018 10:27
ah right. Ok so thing with solidity is that you can't really do float-type calculations
if you need to do those you need to just calculate the numbers with different types of eth
so for example 1 ETH = 1000000000000000000 WEI
and you need to take this into account in your token
so you can't just send 1.2 token, you need to send some subdivision of tokens, like let's say 1 token is 10000 subtoken, so 1.2 token would be 120000 token etc
Markus Streicher
@mstreicher
Feb 15 2018 10:29
casn i do this? price = 0.0002 * 1 ether;
what
RaitzeR
@RaitzeR
Feb 15 2018 10:30
yeah because that's an ether calculation, not strictly a float calculation. The EVM just converts the 0.00002 ether into the actual int value which is 20000000000000 wei
but let me see
can you give me the token code you have
so I can explain this better :)
Markus Streicher
@mstreicher
Feb 15 2018 10:33
is that one from the example just modified the decimal and names
so but that will work? price = 0.0002 * 1 ether;
RaitzeR
@RaitzeR
Feb 15 2018 10:38
yes
but the thing is that 1 ether isn't ACTUALLY 1 ether, but strictly speaking it's 1000000000000000000 wei.
so 1 MarkusToken isn't 1 MarkusToken but something like 1000000000 MarkusSubTokens, depending how your token code is
you can't really have decimals in the ethereum blockchain, at least not in the way you'd like to think about them
Markus Streicher
@mstreicher
Feb 15 2018 10:44
so how can i set the price in this contract?
RaitzeR
@RaitzeR
Feb 15 2018 10:46
what is your decimal accuracy in the token code?
you said you changed it?
Markus Streicher
@mstreicher
Feb 15 2018 10:46
8
RaitzeR
@RaitzeR
Feb 15 2018 10:48
ok so the thing is that when you changed the decimal value, some of the calculations don't hold anymore.
let's say your token is worth the exact same amount as ETH ok
so 1Token = 1ETH
Markus Streicher
@mstreicher
Feb 15 2018 10:51
ok
RaitzeR
@RaitzeR
Feb 15 2018 10:55
when you send 1ETH to the crowdsale contract you actually send 1000000000000000000wei. So in your code you send this amount to the contract, so since ETH and Token are valued the same, but your token only has 8 decimals, in the transfer of the token you will receive a very different amount of tokens
if the decimal accuracy is the same as the ETH decimal accuracy, you don't have to worry about any conversion
so the thing is that when you use the boilerplate crowdsale contract you will have to take into account that your token has different amount of decimals
easier way is to just have a token with the standard 16 decimal points
18* sorry
Markus Streicher
@mstreicher
Feb 15 2018 11:00
ok so i have no chance to change and get the right amount
RaitzeR
@RaitzeR
Feb 15 2018 11:00
well you can calculate it in the crowdsale
but then you're gonna have to remember to always calculate the eth/Token conversion in everything you every code with that token
and anything anyone will ever code
because then you can't just pass over the ETH value to the Tokens transfer method
if you want to say that 1ETH is 10000 token, if you have a standard token you can just super easily do the conversion with a simple ethereum division, but if your Token has a different amount of decimals, in every conversion you're gonna have to take that into account
Markus Streicher
@mstreicher
Feb 15 2018 11:04
but i cant change the token contract
RaitzeR
@RaitzeR
Feb 15 2018 11:04
you will encounter this problem whenever you want to let people pay with ethereum to get x amount of Tokens. Moving tokens around won't have this problem
well is the token already established? Can't you just create a new token contract?
Markus Streicher
@mstreicher
Feb 15 2018 11:04
not with same name?
RaitzeR
@RaitzeR
Feb 15 2018 11:05
sure you can
also some software might have the 18 decimals hard coded for all Tokens (not sure if this is true, but might be), so their conversions might differ from yours
just create another Token contract with the same name, there's no limits to that. If you have published your Token address somewhere, just update it with the new address
Markus Streicher
@mstreicher
Feb 15 2018 11:14
so then the 0.002 * 1 ether will work correctly?
RaitzeR
@RaitzeR
Feb 15 2018 11:16
yes. It might also work now, not 100% sure
you should try it out
there's just probably some problems with conversion
Markus Streicher
@mstreicher
Feb 15 2018 11:34
how i can update the old token now?
RaitzeR
@RaitzeR
Feb 15 2018 11:34
what do you mean?
Markus Streicher
@mstreicher
Feb 15 2018 11:35
i created the same agin
but with 18 decimals
RaitzeR
@RaitzeR
Feb 15 2018 11:37
so what do you want to do with the old token?
Markus Streicher
@mstreicher
Feb 15 2018 11:37
overwrite
or nothing
i jst have a new one?
RaitzeR
@RaitzeR
Feb 15 2018 11:38
well you don't really need to do anything with the old one
you just have a new one
which you will now be using
Markus Streicher
@mstreicher
Feb 15 2018 11:39
ok
Neerav Chauhan
@adneerav
Feb 15 2018 11:57
Hello
How the actually data is getting store in Blockchain ? eg. If I wants to store some data in json structure thn how its gng to actually stored ? is there any example or tutorial from where i can learn about saving data on blockchain on private channel first and main net... ?
RaitzeR
@RaitzeR
Feb 15 2018 12:04
it's stored in bytecode
well, in bytes
with solidity you can store data with these data types http://solidity.readthedocs.io/en/develop/types.html
Neerav Chauhan
@adneerav
Feb 15 2018 12:09
in blocks it will be save in bytes is it ?
that bytes is collection of that values which is given to particular variable or entire smart contracts with value will be stored ?
RaitzeR
@RaitzeR
Feb 15 2018 12:12
ethereum stores the state with mappings from addresses to data
so there's a mapping with an address to the state 0x123456 (your contract state) and there lies your bytes
when the state changes there's a map to the changed state, which stores only the information what changed, not the whole state
Arturo
@arturo393
Feb 15 2018 14:59
I want to know more about ethereum and i am installing geth, Ethereum Wallet and Mist . It seem that each client is downloading it's own blockchain. How can i use the same blockchain for differents clients ?
... maybe my questions is misleading, don't really know.
RaitzeR
@RaitzeR
Feb 15 2018 15:00
if you let one of them finish the downloading, the programs should automatically use the downloaded chain.
the thing with the official eth clients is that if you don't have the full chain downloaded they will start from the beginning
so just let one of them do it's job and should be fine (hopefully :D)
Arturo
@arturo393
Feb 15 2018 15:02
it take so long, what if i close the program an restart later
RaitzeR
@RaitzeR
Feb 15 2018 15:02
then it should continue from where it left off (again hopefully). There's some unfortunate bugs there
but I downloaded my chain with the Ethereum Wallet. Got stuck multiple times, but in the end it got there
Arturo
@arturo393
Feb 15 2018 15:03
that happened to me too
RaitzeR
@RaitzeR
Feb 15 2018 15:03
it should look for the chain data from the default folder, and if it finds it, it just continues with that
Arturo
@arturo393
Feb 15 2018 15:03
and with geth i did not know when the blockchain was fully downloaded
RaitzeR
@RaitzeR
Feb 15 2018 15:04
in Ethereum Wallet you can go to Develop -> Sync with light client
seemed to work for me
Arturo
@arturo393
Feb 15 2018 15:04
so, the client shares the same folder for the blockchain ?
RaitzeR
@RaitzeR
Feb 15 2018 15:04
well it should
in mac it's Library/Ethereum/..
and with geth you can specify which chain it uses, so if it doesn't automatically point there, you can just point it there
Arturo
@arturo393
Feb 15 2018 15:06
do you know where is stored in linux ?
RaitzeR
@RaitzeR
Feb 15 2018 15:06
should be home/.ethereum
~/.ethereum
Arturo
@arturo393
Feb 15 2018 15:11
thanks
RaitzeR
@RaitzeR
Feb 15 2018 15:11
(Y)
Arturo
@arturo393
Feb 15 2018 15:15
i am going to drink a coup of coffe and come back in hours , it is going to take time
RaitzeR
@RaitzeR
Feb 15 2018 15:17
yeah it's a bit of a hassle. But if you just want to develop some things, I recommend using http://remix.ethereum.org - it has an in-memory development blockchain from which you can just try out your contract codes etc
at least you can get your hands dirty on oit
Arturo
@arturo393
Feb 15 2018 15:23
thanks
jalundan
@jalundan
Feb 15 2018 16:40
image.png
Anyone have an idea why I am getting this?
This is straight copy paste from the example, and I am trying to do this in test network
RaitzeR
@RaitzeR
Feb 15 2018 16:42
function transfer(address receiver, uint amount) public;
just add public at the end
jalundan
@jalundan
Feb 15 2018 16:42
ok. trying.
that works, but all of the functions are now the same. should I put public to all of those?
is there any harm if those are public?
image.png
eg I put the crowdsale to public and now it gives error from payable too
RaitzeR
@RaitzeR
Feb 15 2018 16:44
no all of the crowdsale functions are public
I don't think the callback function needs a visibility tag
fallback*
ah I guess it does
Ethereum Wallet is very strict with contract deployment. Doesn't allow you to deploy it even with warnings
2phx
@2phx
Feb 15 2018 17:12
Hello, I am pretty new to this. When making a coin via ethereum smart contracts, do I get a fully functional coin, a coin that people can mine, trade on various exchanges and etc.. ?
RaitzeR
@RaitzeR
Feb 15 2018 17:57
@2phx no
it's just a token, not a full blockchain
but people can trade it
jalundan
@jalundan
Feb 15 2018 18:10
I got the crowdsale contract done, but I get error when trying to send ether to the contract:
"Transaction Error. Exception thrown in contract code."
is there a way to see where it does come from?
there's no change from the example. Only the public declarations
2phx
@2phx
Feb 15 2018 18:19

@RaitzeR .

it's just a token, not a full blockchain

On a website it says that people can mine it? or is that wrong

RaitzeR
@RaitzeR
Feb 15 2018 18:20
well you can't mine it the same way you mine Ethereum. Sure you can write some proprietary code to give people the Tokens if they do certain tasks, like run a program in their computer.
but in the end the Tokens are just a program (smart contract) in the Ethereum blockchain that keeps track how many Tokens an address has

Lets say you have AWESOME Token. You initialize it so you have 50 AWESOME and I have 10 AWESOME:

2phx => 50AWESOME
RaitzeR => 10AWESOME

Then you call a function which says that you transfer 2 tokens to me, then the only thing the program does is just decrease tokens from you and increase for me

2phx => 48AWESOME
RaitzeR => 12AWESOME

so let's say you give your users a task to find typing errors in a white paper. Every time someone finds an error, you give them 1AWESOME token. This is "mining"
or maybe you create a program that finds typing errors in white papers, but it's super computationally expensive. So you tell people "hey everyoen who runs this program will automatically get AWESOME tokens whenever the program finds an error". This is also "mining"
but in a very different way than mining in a blockchain
jalundan
@jalundan
Feb 15 2018 18:26
Hmm... I just can't understand why the example is not working as I did just like in the tutorial (without the organisation). Is the organisation something that you must have if you make a crowdsale that automatically distributes the tokens when ether is sent to the contract?
RaitzeR
@RaitzeR
Feb 15 2018 18:28
@jalundan how did you deploy the code?
jalundan
@jalundan
Feb 15 2018 18:28
Through the ethereum wallet deskpto app
RaitzeR
@RaitzeR
Feb 15 2018 18:29
can you copy paste your code
RaitzeR
@RaitzeR
Feb 15 2018 18:31
your price is set to 0 in the crowdsale contract
so it errors out because it's tryign to divide by 0
jalundan
@jalundan
Feb 15 2018 18:31
oh. lol
I can change that in admin page?
Or is there anyway to edit the contract?
RaitzeR
@RaitzeR
Feb 15 2018 18:32
no you need to redeploy
jalundan
@jalundan
Feb 15 2018 18:33
so just send the fixed code again?
as a new contract?
RaitzeR
@RaitzeR
Feb 15 2018 18:33
send it again, because the code doesn't have a setter for the price so there's no way of modifiying it
jalundan
@jalundan
Feb 15 2018 18:33
ok
If I put to "Ether cost of each token" value "1", does that mean that the price is 1 ether? Because 0.01 is invalid for some reason
RaitzeR
@RaitzeR
Feb 15 2018 18:36
yep then the price is 1
jalundan
@jalundan
Feb 15 2018 18:36
0.00000001 is the first that is not invalid if i want it to be less than 1.
Any clue why?
RaitzeR
@RaitzeR
Feb 15 2018 18:38
I'm not sure :/
Ethereum WAllet is a bit weird
jalundan
@jalundan
Feb 15 2018 18:38
ill try that anyways. funny still that it's ok to put 0.00000000000000001 but 0.1 is not ok and again 1 is ok.
2phx
@2phx
Feb 15 2018 18:42
@RaitzeR
There are other EThash coins, they simple copied the code and made their own EThash coin?
I thought they created those coins contracts

It says here that if someone finds a block on ethereum network, they can get reward from my coin. So how its not mining?

"PROOF OF WORK
There are some ways to tie your coin supply to a mathematical formula. One of the simplest ways would be to make it a "merged mining" with Ether, meaning that anyone who finds a block on Ethereum would also get a reward from your coin, given that anyone calls the reward function on that block. You can do it using the special keyword coinbase that refers to the miner who finds the block."

jalundan
@jalundan
Feb 15 2018 18:52
pfftt... still the same error even with 1 ether price
RaitzeR
@RaitzeR
Feb 15 2018 18:52
@jalundan yeah I was looking at that code and it just seems weird
maybe it's some older version of solidity, which just doesn't work anymore. Doesn't really even look like it would work :D
jalundan
@jalundan
Feb 15 2018 18:53
yeah. the prices etc are given from the ui
i wonder if would just replace the variables with fixed values...
RaitzeR
@RaitzeR
Feb 15 2018 18:54
@2phx can you give me a link to that? I can't really think of any way that would work other than you creating a method in the token contract which is callable by a miner or something
I mean you can find out the miners address and give them the tokens, but what's the point?
all tokens are "premined" anyways
RaitzeR
@RaitzeR
Feb 15 2018 19:00
miners are rewarded coins from a blockchain because they help maintain the network and process whatever the network wants. Your dapp has some functionalities, why not just reward the users with Tokens because they help maintain your dapp. I don't really see a good reason to somehow tie your Tokens to mining on the blockchain
obviously there might be some reasons to it, just nothing pops to mind atm
Found it there
@RaitzeR
RaitzeR
@RaitzeR
Feb 15 2018 19:14
ok, but the code shows a little function on how it might work. It still needs to be called, it's not automatically called by miners
damballah
@damballah
Feb 15 2018 19:14
Hello everyone, it is possible to create an ERC20 token with a Fluctuable Value in the base? For exemple based on the price of rice?
RaitzeR
@RaitzeR
Feb 15 2018 19:14
if you call that method it will give the +1 Token to whoever mines it
but it still needs to be called somewhere and costs gas
@damballah value of what? Fiat money, Ethereum?
@damballah tokens don't have any value inherently
damballah
@damballah
Feb 15 2018 19:18
yes, or like a rice or banana, you know what? exemple, i take one token and he is at 1.00 but he's indexed to the price of rice who is at 2.55, my token become directly to 2.55... Sorry for my english
RaitzeR
@RaitzeR
Feb 15 2018 19:19
aaa okay I get ya. I mean technically sure it should be possible. Just kinda convoluted, and would have to be updated at some predefined intervals
damballah
@damballah
Feb 15 2018 19:20
ethereum, sorry
like tether but better :):)
RaitzeR
@RaitzeR
Feb 15 2018 19:22
:D
Alex Van de Sande
@alexvandesande
Feb 15 2018 19:26
@damballah look into MakerDao and Dai. They’re doing it: it’s possible and they want to make it easier for someone to build that. But it’s super complex to pull it off
damballah
@damballah
Feb 15 2018 19:26
and.... i search for it but i don't find it
@alexvandesande awwww... Ok! i will see this, thanks
damballah
@damballah
Feb 15 2018 19:33
i see it... if i understand correctly, they have a platform
i't like a value of any new token or new coin, how we really can ask a value
Markus Streicher
@mstreicher
Feb 15 2018 19:38
@RaitzeR hey, i just want you to know i use the token with the 8 decimals. I multiplicate the amount in the contract with 100000000. And look it make the rigth payout. Thx for yor help!
jalundan
@jalundan
Feb 15 2018 20:11
Pfft.... I just can't get that to work. Funny that Ethereum's own tutorials does not work. :(