Hello im new to coding in solidity and i am having some problems programming a smart contract. I want to create a basic token with name, symbol and an initial amount. This is my code so far for the Token :
The Token seems to work fine I can create it send it etc.
Now i also want to create a crowdsale for this token meaning that other wallets can send ether to a specific account to receive my token. So far my code for the crowdsale looks like this:
I can deploy the crowdsale contract just fine however i cant buy tokens from the contract. After creating the token i of course sent the created tokens to the crowdsale contract however i was still unable to purchase the error message i am getting is: “Gas price could not be calculated, transaction will most likely fail”
My guess is that my contract doesnt link my created token to the crowdsale. Any help would be greatly appreciated
Did not work. Also im kinda wondering When i deploy the Crowdsale contract i put in an address which holds token and an adress where the ETH is supposed to be sent to. However once deployed the contract only has the function “buy tokens” where i only need to put in a beneficiary address. How is that supposed to work if i cant even put in an amount to “buy”
Okay so i figured out that the smart contract has its own adress so im guessing to “buy” the crowdsale tokens i have to send ETH to that adress. However this also fails with the Error message: " Transaction reverted smart contract failed to execute" on MyEtherWallet. So i am guessing something is missing from the code.
Because you have to put the amount on the wei section on Remix. Anyway you can modify your code to receive BNB in this way:
User send bnb to the contract address and receives tokens based on a rate you choose
I think i have to transfer ownership of the token to the contract apparently just having the tokens in the wallet specified in the smart contract is not enough. Do you think that could be the issue ?
If you do not want us to know the Token name, it would be useful to follow these steps anyway.
Is code optimization turned on?
How did you compile the code? Please, if you want help to the smallest detail, you can distribute the code in a different name in the test network as you did it. Dude now send some ether to the contract address! Up to 0.001! I assume it exists in the main network. If he sends you tokens in return, we will have to tie a new contract to this contract!
This contract will send directly to the other contract and sell through the other contract. The cons of this situation are that the user pays more gas when buying. Or if you want the cleanest and the coin has not spread yet, I suggest you start over. We can only help that much without knowing the details. Good luck with.