I am a beginner in writing smart contract. I want to deploy a crowdsale and token contract on the Kovan testnet. Everything works well except when I tried to send KTH to the crowdsale contract. I always get "reverted transaction" in the end. Could someone help me solve this situation? I am using the standard Crowdsale and Token sale contract from openZeppelin and truffle suite.
Crowdsale contract: https://kovan.etherscan.io/address/0x68321f1380ac45be3f3d85d0cd95d1ac5710b8a9#code
Token contract:
https://kovan.etherscan.io/address/0xb76b6ae76cee43e0b32588ffc112efca3c781f1e#code
Related
Remix is telling me "Currently you have no contract instances to interact with." But that's because Remix Won't Allow me to deploy my contract. Please Help I'm new to thisPicture of my remix smart contract
You have not compiled your smart contract. You need to first compile your smart contract only then you can deploy your smart contract.
Is there a way to automate an ERC20 token deploy? Can a contract receive some parameters to configure the new token and then deploy it returning the new token address?
I'm trying to create a contract that speaks with a dapp which instructs the contract to create and then deploy a given ERC20 token with the given parameters (name, sym, decimals...)
Is this possible?
I've found that a Dapp can deploy a contract:
https://ethereum.stackexchange.com/questions/36698/deploying-a-smart-contract-using-dapp
But can a contract deploy a contract? Is this too pricy?
But can a contract deploy a contract?
Yes. A contract can deploy a contract.
See for example Uniswap v2 UniswapV#Factory deploying pair contracts using CREATE2 (deterministic deployed contract addresses).
Is this too pricy?
This is a business model question and cannot be answered based on the information you provided in the question.
Learning Solidity along with token development.
I'm having a hard time understanding how tokens with multiple smart contracts interact with each other.
I've read through other tokens with multiple contracts on GitHub and reviewed contracts on OpenZeppelin but they all appear somewhat orphaned.
Let's say we developed a token that has a supply and tracks wallet address to amount using a map. The contract is released and is given an address. Admin or privilege methods are protected via owner address validation. Then we release a second contract that needs to make apply a fee for transactions.
How does the second (token transaction fees) contract interact with the data stored on the first (token contract)? Does the second contract need to also verify ownership?
Any contract on Ethereum can interact with any other contract by using Interfaces. You can call methods from the second contract on the first contract for an ERC20 token as below:
Define ERC20 Interface
interface ERC20 {
function balanceOf(address account) external view returns (uint256);
}
Use the interface and token contract address to call methods on the first contract:
ERC20(tokenContractAddress).balanceOf(0xabcd....);
The similar approach can be used for any contracts
as most of the BEP20-Tokens-Contracts are online available on GitHub or BSCScan you should be able to just copy the code and paste it into remix.ethereum.org and deploy it. I did that and the contract deployed successfully to the BSC but the token information are missing. What do I do wrong?
Here is the code I copied: https://bscscan.com/address/0x0cF011A946f23a03CeFF92A4632d5f9288c6C70D#code
and here is my contract deployed to the BSC: https://bscscan.com/address/0xf5be6f7f00a4870b46f3ab6d16f5095731da97d7
I have just changed the name of the token, but the token information are not showing up on BscScan nor do I see the token in my Wallet. Any help is appreciated!
Your contract's bytecode contains just the Address contract bytecode. Since it's the first contract in the list (sorted alphabetically), I assume you simply forgot to select the contract that you wanted to compile.
You need to select the NyanCatToken contract (which effectively imports the Address as well) when compiling in Remix.
I have an Eth contract, called the controller, which is used to:
Generate new eth deposit addresses, one for each user, which is
an eth contract as well.
Sweep these deposit contracts when a user deposits eth or erc20 token to them. The funds end up in another central eth account.
A number of erc20 tokens seem to work perfectly, but USDT deposit transactions get reverted: https://etherscan.io/address/0x3cd5a0dc36a8f22011193f2a03910aa8260e64db
Without the original source code for these contracts (although I have the JSON ABI), it is hard to say:
Why it fails for USDT.
If these actually can support USDT, or what it would involve to do so.
If anyone can point in the right direction, it will be appreciated!
Controller contract:
0xEb818C6a48cCd60A8078aaa20997cC3CB2538C9E
Another contract involved linked to controller, called defaultSweeper:
0x8e7ABAF1316A0edB985e494F572Fdf148e8a7E93
EDIT:
It seems that USDT contract is missing some erc20 methods. Like transfer See: https://erc20-verifier.openzeppelin.com/ Why is this?
Tether contract was deployed before the ERC20 standard was finalized. Some functions don't follow the specs, for example transfer should return a boolean and it doesn't.
Recent versions of solc will check the returned data size is correct (since 0.5 I think).
My guess is that your contract was compiled with a recent version of solidity and it uses the standard ERC20 interface. And it fails because Tether returns nothing and it is expecting a bool value.
There isn't much you can do. Either Tether should upgrade its contract or the controller contract has to be modified to do not check the contract size. See SafeERC20 from OpenZepplin, they implemented a wrapper around ERC20 that allows interfacing with tokens that are not compliant with the standard.