New answers tagged

0

Just type the variable you set your promise to assign to and it will output the value to the terminal.


0

Hey were you able to find a solution for this? The same thing just happened to me. I have a fairly large amount stuck in a smart contract address that I'm scared to withdraw. I sent a smaller test transaction to the wallet I believed was compromised, and sure enough, the funds were stolen shortly after. I will checkout the other possible solutions mentioned ...


0

did you get error like "This contract may be abstract, not implement an abstract parent's methods completely or not invoke an inherited contract's constructor correctly."?


0

while keeping the same address ideally. Addresses are interchangeable between the networks. The smart contract address is the deployer address + nonce. You just use the same private key to deploy the address on every network. I need shared state between networks? It is impossible. Each network is independent of each others and they do not verify blocks ...


1

You have typo in function definition it should be returns instead of return. function transferFrom(address from, address to, uint value) public returns(bool)


0

The contract THEOSARS has several issues: The mappings balances and allowed are duplicated in THEOSARS, StandardToken and BasicToken mapping (address => uint256) public balances; mapping (address => mapping (address => uint256)) public allowed; Solidity creates two unrelated copies. More recent version of solc issue a warning when two variables ...


0

As you can see from the pancakeswap contract code, this error is triggered by this: require(amountIn > 0, 'PancakeLibrary: INSUFFICIENT_INPUT_AMOUNT'); The contract thinks that the amount that you are trying to swap is 0. Your transaction does include a value of 0.01 BNB to swap and this is what the contract should use as amountIn. I am not sure why it ...


0

Exporting your private key is better than exporting your Brave Wallet mnemonic, since Brave mnemonics are incompatible with other wallets. Go to brave://wallet/crypto/accounts Click on the account name you want to export Click the Pencil icon on the right Click Private Key


1

Hope the following gives you a good over. Advantages Testnet node needs to sync and store much less data Testnet node can sync in a couple of hours Deploying contracts can be done using "test Ether" which is free Testnets are public blockchains and contain many other users and contract that run live, making it pretty realistics Disadvantages ...


2

Ethereum transactions are done with public-key cryptography. It does not matter if ABI is known or not. If the hacker does not have a private key of the victim, the hacker cannot pose as a victim or do any harm.


0

In transfer function first calculate amountToBurn then subtract it from amount to get amountToTransfer. uint256 amountToBurn = calculateBurnAmount(amount); uint256 amountToTransfer = amount - amountToBurn; _transfer(_msgSender(), recipient, amountToTransfer); _burn(_msgSender(), amountToBurn); remove burn function


0

Max supply is how many tokens can ever exist. It's selected arbitrarily, and you don't even need to have it (e.g. USDT - it can be minted up to the integer limits). Often I see tokens picking a round number like 1000000000 for simplicity. Total supply is the number of currently minted tokens. How you mint them is also entirely up to you. Circulating supply ...


0

I had the same problem, here is your answer: I wrote my own script to mimic his and figured out the function triggers when BNB is deposited in an amount>the gas required to move it. So i can send increments of .00005BNB to my wallet and his program wont pick it up... it will take a while but its worth it if you want those tokens back.


1

You're trying to call a function from within the constructor, it shouldn't even compile (ie "addPair() is not (or not yet) visible at this point."). Either copy the logic of your function into the constructor or call this function after deployment.


0

It basically works as the Safemoon token's source code. Any transfer's amount is tAmount, and then: rAmount = tAmount.mul(currentRate); currentRate is just rSupply/tSupply in most of cases (except for excluded addresses). Take a look to balanceOf and tokenFromReflection functions to properly understand the reflection and how the fee sharing is done across ...


1

You should do that off-chain if you can. For an off-chain solution see Get a list of all token types for ERC1155 To get all tokens of an account within a smart contract you'd have to add enumeration. Openzeppelin doesn't have it to reduce gas costs. I use solidstate, it has an enumerable extension (it's designed for eip-2535, but you can still use it) https:/...


1

You should use a hash function on your ids combined with the random number. tokenIds are randomly distributed (can repeat): for (uint256 i = 0; i < tokenIds.length; i++) { tokenIds[i] = uint256(keccak256( abi.encode(randomNumber, i) )) % tokenIds.length; } tokenIds are randomly shuffled (can't repeat), this naive shuffling isn't very good ...


0

The choice to use ERC 721 or ERC 1155 solely depends on your use case. ERC 1155 is a kind of extension to ERC 721, as it can create fungible as well as non-fungible tokens. So, if you want to stick your smart contract to mint true NFTs only, then ERC 721 is a good choice, but if you are unsure at this stage then you can deploy ERC 1155, and keep passing 1 ...


1

what you can do is have a mapping that tracks which NFT belongs to like this: mapping(uint256=> string) public nftsCollections; //whenever you mint an nft require the admin to pass the collection name and //add it to this collection nftsCollections[id]=collectionName;


0

Every cryptokittie is an nft of its own. You shouldn't do it in ERC1155. Every time a cryptokittie is created you mint a new nft token, you don't add to the token already existed. If you use ERC1155 you enable the option to own more than one instance of the nft which denies the whole purpose of it.


0

what you can do is have a mapping that tracks which NFT belongs to like this: mapping(uint256=> string) public nftsCollections; //whenever you mint an nft require the admin to pass the collection name and //add it to this collection nftsCollections[id]=collectionName;


0

The answer for this is simple, put the token URI via api of your dapp, then save the token id on your database everytime mint success. If anyone publicly mint through bscscan or ethscan or any block explorer, it will be invalid and unusable. Like process of banning.


0

This is what I understand. Wrapped token: represents a token non-native to the blockchain it is presently on. Pegged token: is not a thing. A wrapped token would be 'pegged to' a non wrapped token to preserve the value of the wrapped token. To further elaborate: Your question is linked to moving tokens from one blockchain to another. When 1 ETH is moved ...


0

Let's say you have contract A where your internal _burn function is implemented. Through inheritance in Contract B you can call the internal function in Contract A in a public function you declare in Contract B named burn: Contract A{ // default logic function _burn(address account, uint amount) internal virtual{ } } Contract B is Contract A{ //default ...


0

Yes, this is a common question. I have fully spelled this out as a demo project including the smart contracts and the front end JavaScript. https://github.com/fulldecent/spend-ERC20-create-ERC721 This project was sponsored by Arianee.


2

So the math is as follows, 1 coin = 1 * 10**3 = 1000 So 1 coin for 1 wei = 1000 coins for 1 wei since the coin is of 3 decimals. Hope this answers your question


0

If you've enough liquidity, you can use an oracle like chainlink and swap inside your smart contract/website with some simple logic. But in most cases, we don't have enough liquidity. So the uniswap contract comes in handy. You can import the UniSwap router inside your smart contract and do the swap within your same smart contract in one atomic transaction. ...


1

_totalSupply is defined as a private storage variable in the ERC20 contract: uint256 private _totalSupply; Thus no contract, not even child contract like yours, can write directly to _totalSupply. If you want to mint a specific amount of tokens in the constructor, you have to use the _mint function.


Top 50 recent answers are included