2

So lets begin from there that if you don't want to receive ETH your functions doesn't have to be payable. For points 1) and 2) this code will help: interface ERC20 { function transferFrom(address sender, address recipient, uint256 amount) public returns (bool); } contract Name { mapping(address -> bool) supportedStableCoins; mapping(address -&...


2

The bytecode is not CBOR-encoded as a whole. Only the part representing the metadata hash at the end is and you seem to be decoding it correctly. As to why it can start with 0xa264, 0xa265 or something else see my earlier answer for "How to verify smart contracts on different solidity versions". Am I right to distinguish runtime bytecode and ...


2

Tokens transfers can either be triggered by the owner or an approved spender of the tokens, so from will not always be msg.sender. Having a single implementation to handle both cases is more elegant.


2

Solidity is not like the other languages. You can think of the storage as empty array so even if you have never used a mapping for eg. Players[12334] its value is not nil/null/nullptr it is the default value for the type. In your case the default value for address is the zero address (0x000.../address(0)). If you want to delete player it is enough to set it ...


1

From what I can see, it can be read. If the id variable was declared private and not internal in that case, you'd not be able to access it from child smart-contract Screenshot from remix - on the contract specified above. Maybe you just had a mistake and deployed parent - instead of child contract.


1

You can try this: function mint(uint256 _amount) public { //Now you call the internal mint function from your ERC20 token //You can find more about it here //https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol _mint(msg.sender, _amount); }


1

Basically if you define struct outside the contract you are making it public and every contract which iport the .sol file could use it where as if it is in the contract scope it is private and only the contract itself could use it. Also if it is outside you cold have problems with same named contract. Example: struct Test { ... } contract Test { ... }


1

The refresh of the page when you click a button is probably due to the submit event method not being prevented to happen. Example to prevent refresh onClick={(event) => Migration1(e)} function Migration1(e){ e.preventDefault() // <---- this prevent the form from being submited and run your code instead } The part you call ethers is not. It's ...


1

This error is probably not caused by the contract or the deployment. non-200 status When you contact the RPC to deploy you don't get an OK http 200 status. This mean that you can not connect to it. https://developer.mozilla.org/fr/docs/Web/HTTP/Status/200 the other code 403 if from the http protocol. https://en.wikipedia.org/wiki/HTTP_403 Your errors are ...


1

a possible way to write your testcase is like this: const Contract1 = artifacts.require("./C1.sol"); const Contract2 = artifacts.require("./C2.sol"); contract("Test", accounts => { let result; // First contract // Do these tests first to modify the state of C1 it("First test", async () => { ...


1

You can achieve this with OpenZeppelin using the following code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20FixedSupply is ERC20 { constructor() ERC20("Fixed", "FIX") { _mint(msg.sender, 1000); // Mints 1000 tokens to your wallet ...


1

Yes, the users have to call the approve function "themselves". (Otherwise, you would just be able to approve anything you want :) ) But they don't have to do that manually - usually how it works is that your front end website will issue for the user two transactions to sign - one for approving the ERC20, and one for executing your smart contract ...


1

Edited Answer The reason people like using uint256 for most calculation is that OpenZeppelin has a SafeMath library for uint256 that prevent number overflow for sol version < 0.8. Additional casting will cost gas, so it's more efficient to keep number as uint256, and do math calculation all in uint256, instead of reading a shorter bit number and cast it ...


1

It basically checks that the value of localCounter has increased only by one. That means the function has been called only once (within the transaction). The actual function is executed at _;. Before that it increases the counter by one and assigns the value to a local variable (opposed to the global variable _guardCounter). If the function calls itself, the ...


1

Your function needs to return an array in order to work: function getWallet() public view returns (WalletTeam[] memory) { return walletTeam; }


1

Thanks to Cameel's answer I realized that I could just test myself in Remix using compiler older than v0.5. I did so, because I wanted to verify the answer, and it was correct. Since this approach is good for other noobs to use, I post it here as an answer. Solidity version has to be one that has included the abi.encode/encodePacked methods (added in v0.4.24)...


1

Fixed it! The gas was too high, I changed "4294967295" to "4294967" and it worked.


1

Your actual code should only show you the balance of NFT owned by the account on your contract. connectedContract Appears to be your contract. So the Balance is related to that contract. If you did not implement the Enumerable set. To get all the NFT's of an account you would have to loop over them and call connectedContract.ownerOf(token_id).call() An ...


1

Yes, others can decode the data as well. No matter what product you use to store passwords, the process is always similar. No password should be stored as is. It should be hashed. However in your case, The blockchain is public, therefore the hash of the password would be visible to anyone. You should reconsider the use of password. You can trust that msg....


1

The problem is because you are using a compiler version older than 0.6. The solution is to use a compiler version more than or equals to 0.6 OR you can declare the investor field in your struct as address payable instead of address and you will not need to use the payable function because you will be able to transfer/send directly like this: orders[i]....


1

You can't push value into mapping, this only works with arrays. You can, however assign values to mapping at a specific index. For ex: wallet[id][msg.sender] = value;//where value is an uint If you have an array inside the mapping, then you can push values into that array like this: mapping(uint256 => mapping(address=>uint256[])) public wallet; ...


1

It was abi.encodePacked(). keccak256(abi.encodePacked(a, b, c)) on 0.5+ is equivalent to keccak256(a, b, c) in earlier versions. Solidity v0.5.0 Breaking Changes > Semantic and Syntactic Changes The functions .call(), .delegatecall(), staticcall(), keccak256(), sha256() and ripemd160() now accept only a single bytes argument. Moreover, the argument is ...


1

The difference can be explained by how the compiler implement those types. bytesNN is fixed sequence of NN bytes while string is a dynamic array of bytes. Using string increases the runtime bytecode due to a few auxiliary function included by the compiler. For a public variable the compiler has to create a getter function. A constant declaration will be ...


1

Once you deploy a contract, the ABI is not natively available anywhere online. If you just have the contract address, you can only get the ABI by two means: Reverse-engineer the contract. Not fun nor easy Get the ABI from a third party service, where the ABI (or source code) was uploaded to. Such as Etherscan. This of course won't work if the ABI (or the ...


1

So lets imagine that the pool.token contract in the first function is somehow compromised and now the pool.token.safeTransfer() function is not only transferring the token but also calling again the emergencyWithdraw(). When the function is entered for second time the user.amount will not be 0 and the user will get 2*user.amount instead of once and this will ...


1

Check getFeeData int etherjs documentation. Since the gas cost of solodity function is pretty much equal every time you can make average of 10, 20 calls on test net You can calculate the feePrice*gas*ethPrice to get some approximation what it would cost EDIT: Updated for an EIP-1559 transaction


1

The blame is on _isApprovedOrOwner it is calling explicitly the implementation on ERC721 due to ERC721.ownerOf. function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (...


Only top voted, non community-wiki answers of a minimum length are eligible