How do I verify a factory contract in etherscan rinkeby? - solidity

I tried to create a factory for ERC-20 token in rinkeby network taking reference from bscscan-BEP20Factory. But I am not able to verify the contract. The link for my contract is here.
My Contract code is:
pragma solidity 0.8.4;
import "#openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "./interfaces/IProxyInitialize.sol";
contract ERC20TokenFactory{
address public logicImplement;
event TokenCreated(address indexed token);
constructor(address _logicImplement) {
logicImplement = _logicImplement;
}
function createBEP20Token(string calldata name, string calldata symbol, uint8 decimals, uint256 amount, bool mintable, address erc20Owner, address proxyAdmin) external returns (address) {
TransparentUpgradeableProxy proxyToken = new TransparentUpgradeableProxy(logicImplement, proxyAdmin, "");
IProxyInitialize token = IProxyInitialize(address(proxyToken));
token.initialize(name, symbol, decimals, amount, mintable, erc20Owner);
emit TokenCreated(address(token));
return address(token);
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IProxyInitialize {
function initialize(string calldata name, string calldata symbol, uint8 decimals, uint256 amount, bool mintable, address owner) external;
}
Following is the error:
enter image description here

Related

when i am running code in remix id it does not give error while in vs code it gives me error after installation solidity extension

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.7;
contract Transactions {
uint256 transactionCount;
event Transfer(address from, address receiver, uint amount, string message, uint256 timestamp, string keyword);
struct TransferStruct {
address sender;
address receiver;
uint amount;
string message;
uint256 timestamp;
string keyword;
}
TransferStruct[] transactions;
function addToBlockchain(address payable receiver, uint amount, string memory message, string memory keyword) public {
transactionCount += 1;
transactions.push(TransferStruct(msg.sender, receiver, amount, message, block.timestamp, keyword));
emit Transfer(msg.sender, receiver, amount, message, block.timestamp, keyword);
}
function getAllTransactions() public view returns (TransferStruct[] memory) {
return transactions;
}
function getTransactionCount() public view returns (uint256) {
return transactionCount;
}
}
If the code doesn't provide error in Remix, its fine. Solidity extensions/linters in VSCode are not a reliable source of errors.

PancakeSwap Why the swapExactTokensForEth not transfering the result token to the target address?

I want to ask if my contract is wrong or faulty since I created a simple swap contract with the pancakeswap router on testnet and the transaction has been succeed but the result token from the swapping is not transferred to the target address.
Below is the transaction URL from BSCScan testnet:
https://testnet.bscscan.com/tx/0xdaff70143fff6f1be08d20c31ebbfdb8117d067f9311fa130c189722f499ef09
This is the pancakeswap from the testnet:
https://pancake.kiemtienonline360.com/#/swap
This is the contract that I used to to the swap to the router:
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
interface IPancakeswap {
function swapExactTokensForETH(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function WETH() external pure returns (address);
}
interface IERC20 {
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
function approve(address sender, uint256 amount) external returns (bool);
}
contract SwapProject {
IPancakeswap pancake;
constructor() {
pancake = IPancakeswap(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3);
}
function WETH() external view returns(address){
address wbnb = pancake.WETH();
return wbnb;
}
function swapExactTokensForETH(
address token,
uint amountIn,
uint amountOutMin,
uint deadline
) external {
IERC20(token).transferFrom(msg.sender, address(this), amountIn);
address[] memory path = new address[](2);
path[0] = token;
path[1] = pancake.WETH();
uint deadlinePro = (deadline * 1 minutes) + block.timestamp;
IERC20(token).approve(address(pancake), amountIn);
pancake.swapExactTokensForETH(
amountIn,
amountOutMin,
path,
msg.sender,
deadlinePro
);
}
}

Definition of base has to precede definition of derived contract (ERC721 implementation)

The top SO or ETH Stack Exchange answers don't seem to apply to my case (I could be wrong of course)
I'm getting the error describer in the title in this file:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC721Metadata.sol";
import "./ERC721.sol";
contract ERC721Connector is ERC721Metadata, ERC721 {
// ^^^^^^^ (Definition of base has to precede definition of derived contract)
constructor(string memory name, string memory symbol) ERC721Metadata(name, symbol) {}
}
Here's what ERC721Metadadata looks like:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ERC721Metadata {
string private _name;
string private _symbol;
constructor(string memory named, string memory symbolified) {
_name = named;
_symbol = symbolified;
}
function name() external view returns (string memory) {
return _name;
}
function symbol() external view returns (string memory) {
return _symbol;
}
}
And here is what ERC721 looks like:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC721Metadata.sol";
import "./ERC721Connector.sol";
contract ERC721 {
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
mapping(uint256 => address) private _tokenOwner;
mapping(address => uint256) private _OwnedTokensCount;
function _exists(uint256 tokenId) internal view returns (bool) {
address owner = _tokenOwner[tokenId];
return owner != address(0);
}
function _mint(address to, uint256 tokenId) internal {
require(to != address(0), "ERC721: minting to the zero address");
require(
!_exists(tokenId),
"ERC721: minting a token that already exists (been minted)"
);
_tokenOwner[tokenId] = to;
_OwnedTokensCount[to] += 1;
emit Transfer(address(0), to, tokenId);
}
}
Do you need to import ERC721Connector contract in your ERC721 contract? If not, you can remove
import "./ERC721Connector.sol"; // line 4, ERC721.sol
from your file and it should work fine. Your imports are causing the issue,
ERC721Connector tries to import ERC721, but ERC721 also needs ERC721Connector so the compiler says
Definition of base has to precede definition of derived contract
Because the base contract doesn't precede the defined contract.

TypeError: Data location can only be specified for array, struct or mapping types, but "calldata" was given

I created a function that stores data. But this function cannot receive data. I tried it without calldata, with memory but all this ways didn't work. Thanks for the help.
pragma solidity >=0.7.0 <0.9.0;
contract Test {
struct Messanges{
string message;
address sender;
}
Messanges[] public chatverlauf;
address a = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
function add(string calldata _message, address calldata _sender) public{
//chatverlauf.push(Messanges(_message, _sender));
Messanges memory newMessage;
newMessage.message = _message;
newMessage.sender = _sender;
chatverlauf.push(newMessage);
}
i lookt up in this but it didn't workt for me
https://ethereum.stackexchange.com/questions/83602/data-location-can-only-be-specified-for-array-struct-or-mapping-types-but-mem/83603
written with remix
the compiler version is 0.8.10
change
function add(string calldata _message, address calldata _sender) public
to
function add(string _message, address _sender) public
In Solidity 0.8.0 only array , struct and mapping type can specific data location.

Why can't I transfer USDT to my smartcontract?

When I call transferUSDT i got a 'BEP20: transfer amount exceeds balance' but i know i got suffisent funds. I think i miss something in my smart contract.. Here the error on the bscscan:
https://testnet.bscscan.com/tx/0x3a253a8c32ed19bdbed66499ec2f888eae5114d44eba7c2f28a185258e91641f
pragma solidity >=0.7.0 <0.9.0;
abstract contract IUSDT{
function approve(address _spender, uint _value) virtual external returns (bool);
function transferFrom(address _from, address _to, uint _value) virtual public;
function transfer(address recipient, uint256 amount) virtual external returns (bool);
}
contract usdtTransfer{
IUSDT TetherContract;
function transferUSDT(uint256 amount) public {
TetherContract.transfer(address(this),amount);
}
constructor(address _tetherAddress){
TetherContract=IUSDT(_tetherAddress);
}
}
TetherContract.transfer(address(this),amount);
This snippet is trying to transfer amount (2nd argument) of tokens to the address(this) (1st argument) address - which is the address of the usdtTransfer contract.
And since it's executed from the usdtTransfer contract, it's trying to send the tokens from the very same usdtTransfer address.
If your goal is to send the tokens from the user to your contract, the user needs to first execute the approve() function on the token contract (from their address, passing your address as the spender param).