1

I copied this token contract from Ethereum.org, and after deploy to Rinkeby, I could not buy tokens. I really do not know why, but I think that's because I did not set the gas on contract. is there any way to set gas on this contract?

The error: enter image description here

1

Even if you have copied the smart contract code from ethereum-github, then also will show not enough transaction fees, this transaction will fail. Because you have to write a function to transfer the ether or reward the smart contract-address may receive to another account as once the smart contract is deployed, you can never transfer it to any other address.

To do so, you need to write following function into your smart contract code:

Declare these 2 variables

address public coinOwner;

uint public receivedMoney;

mapping (address => uint) public pendingWithdrawals;

Add payable keyword after public in Constructor.

Add these 2 functions also:

function sendReceivedMoneyToOwner() public payable returns (bool) {

    if (msg.value > receivedMoney) {        
        pendingWithdrawals[coinOwner] += msg.value;

        coinOwner = msg.sender;

        receivedMoney = msg.value;

        return true;

    }

    else {

        return false;

    }

}

function withdraw() public {

    uint amount = pendingWithdrawals[msg.sender];

    // Remember to zero the pending refund before

    // sending to prevent re-entrancy attacks

    pendingWithdrawals[msg.sender] = 0;



    //msg.sender.transfer(amount);

    if(!msg.sender.send(amount))

    {

        revert();  //throw;  BUT throw is deprecated!

    }

}

You can get further details for the same here

Hope It helps!

0

I usually have this problem because of poor connection. Restart your wallet and wait until "Looking for peers..." text is gone



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.