3

Whether or not you need to declare memory, storage, or calldata depends on if your variable is a "complex" variable or not. (See the note here.) This means things like structs and arrays. Simpler types are automatically assigned storage - see this question and anwser. To answer fully, bytes32 will automatically be storage even without a data ...


3

This is basic mathematics. uint256 percent = 72; uint256 fee = msg.value.mul(percent).div(1000);


3

As mentioned by Linum Labs, that approach can be used for solidity v 0.7 and higher. If you want to use an older version, From docs: \uNNNN (Unicode escape) You will need to convert Unicode character to escape sequence, For example: ✕ray Ýour ℤen will be \u2715ray \u00ddour \u2124en And Important NOTE from docs: Any unicode line terminator which is not a ...


3

Welcome! Just as a quick note, you mention "smart contracts" in the question, but give code that looks like Solidity, and also have a Solidity tag in your question, so I assume that the question's focus is Solidity. Different languages may handle Unicode differently, so the answer can change from language to language. Solidity (v0.7 and higher) (...


2

As far as chainlink price feeds are concerned, ETH pairs (USD/ETH, AAVE/ETH, UNI/ETH, etc.) have 18 decimals while non-ETH pairs (ETH/USD, etc.) have 8 decimals. Source solidity integer division automatically rounds off towards 0.(Docs Reference), so you can do price/10**8 to get rounded off integer for dividend representing 8 decimals. To verify the value ...


2

Make sure HDWalletProvider is updated to latest and then pass the chainId as an option to HDWalletProvider. For rinkeby its 4. The next version of HDWalletProvider will auto fetch the chainId, but it doesn't do this yet. This feature will likely will be released next Thursday or Friday. This only started happening now because geth recently began defaulting ...


2

It is possible to have a private key in a solidity contract but everything on the blockchain is public so anyone will have access to the private key. In other words, it is not possible to properly place the private key on a verified contract while restricting the access only to a specified target. The private keyword doesn't obfuscate data. For example it is ...


2

(Answering myself two year later for those arriving here through Google Airlines): "new" keyword is the culprit in this case. Each time "new" is used, the full code of the referenced smart-contract will be included in order to allow to build new SubContract instances at runtime. If just pre-built references are passed, the compiler is ...


2

The short answer is to remove it. More background It's changed more than once. That syntax dates back to a time when the default, undeclared fallback function was payable and could receive funds. That function looks like a guard to make sure it doesn't happen. That default behavior was removed so there should be no need to block it. The newer versions have ...


2

The first push consumes 41129 gas That'll be 21,000 gas for the transaction base fee, and 20,000 gas for using the storage associated with the array for the first time. (Plus 129 gas - unsure about this, but probably unimportant.) while the second one only consumes 26129 That'll be 21,000 gas for the transaction base fee, and 5,000 gas for updating the ...


2

The (theoretical) total storage for a contract is 2^256 * 32 bytes regardless of how you store it. That number is huge, you'll run into issues long before filling that storage. I don't think there's a max number of Events that you can emit. However you'll probably limited by gas cost and block gas limit.


2

Substitute x for whichever number you want to check for. function highestOrderDigitIsX(uint256 number, uint256 x) public pure returns (bool) { while (number >= 10) { number /= 10; } return number == x; } For completeness: function lowestOrderDigitIsX(uint256 number, uint256 x) public pure returns (bool) { return number % 10 =...


2

There is an explanation in the original Github ERC721 thread about keeping the "unsafe" transfer function (comment from Dieter Shirley, alias "dete", one of the authors of EIP-721) : Upon further reflection and discussion with @flockonus, we are proposing to keep a straightforward (and therefore "unsafe") transfer() method. (i....


2

The more comprehensive explanation can be found here: What are Artifacts In short, truffle artifact is a JSON bundle that contains a lot of useful information related to a contract like the ABI, the contract bytecode, the deployment details, compiler version, etc...


2

You can use the CHAINID opcode to get the current chain ID. AFAIK, Solidity does not have a built-in function for this, but you can use inline assembly to get the chain ID in a Solidity contract, e.g.: function getChainId() private view returns (uint256 chainId) { assembly { chainId := chainid() } } Then you can check if the chain ID is 1 for ...


2

For instance: 1️⃣is has three characters: The digit one: 1, variation selector, a Combining Enclosing Keycap. It does have 3 characters, but they take 7 bytes. But in Solidity, 1️⃣ is counted as 7. You are treating the text as bytes, so it's correctly returning 7. One option would be to count the number of bytes - instead of characters - in JS on your ...


2

You can use web3.eth.abi.encodeParameters: const web3 = new Web3; web3.eth.abi.encodeParameters( ['address', 'uint256[]'], ['0x6b175474e89094c44da98b954eedeac495271d0f', [1, 2, 3]] ); Results in: ...


2

This is a very important topic, and it's been pointed out that not enough attention is given to it. Ultimately, immutability is a bit of a spectrum. If somehow every last device storing the Bitcoin and Ethereum networks would be destroyed, the networks would be lost. Fortunately, that is improbable enough to not worry about. Similarly, even IPFS is not as ...


2

For whoever need to find an answer to this question like I did: "An address a can be converted to address payable via payable(a)." So you can do address payable nftAddress = payable(address(nonFungibleContract));


2

On the left of the Remix workspace is the "Icon Panel."https://remix-ide.readthedocs.io/en/latest/layout.html At the top of that is the Remix logo icon that looks like a head with headphones. Click the Remix logo icon to open the "Home Page." On the Home page, on the left is a "File" section. In the File section is a link to &...


2

You can have multiple functions with the same name, as long as their signature is not the same. The parameters are also part of the signature, so the function signature of those two functions is different. So the functions do not get mixed up in any way. Whenever you call a contract function, you have to provide the parameters as well. The executed function ...


1

From Solidity v0.8.0 Breaking Changes https://docs.soliditylang.org/en/v0.8.0/080-breaking-changes.html ABI coder v2 is activated by default. So it is not experimental, but standard feature since solc v0.8.0


1

_lp is the Pancake liquidity provider token to stake in the farm pool and wbnb is a wrapped BNB token on Binance Smart Chain.


1

First of all, ERC721 has its amount fixed as 1, so you might wanna use ERC1155. If you want to create 1500K ERC721 or 1500 ERC1155(1K of each) collectibles, I would not suggest you create all of them in one go, as there is a high possibility that they will exceed the block gas limit. From your question, I see that you have all the different token URIs stored ...


1

This answer is about nightly builds in general and not specific to solidity. A nightly build, in general, is a build of a version, that is not finished yet. So there might be more bugs or missing features. It is basically a build of the current work in progress. It is called nightly build because it is common to automatically build them from the current ...


1

You error is not related to nightly builds. One of your files (SafeMath.sol) requires a compiler version (pragma solidity ^0.4.23) lower than the one you selected (0.8.3).


1

NFTs are auctioned in various ways on various platforms. An auctions could theoretically be completely centralized - an owner says they're taking bids until a certain time, potentially even off-chain, and at the end of the time, the bidder informs the winner they have won, accepts their payment, and sends the NFT. There wouldn't be much you could do with a ...


1

const TodoList = artifacts.require("TodoList"); // Enter your Contract Name not File name module.exports = function(deployer) { deployer.deploy(TodoList); };


1

When you hit "Compile ww1.sol", the remix will compile all contracts inside that solidity file. After compiling the ww1.sol, If you change Context (Context.sol) to NiftToken (ww1.sol) (NOTE: don't click compile again after changing to NiftToken) and then click on compilation details then you will see the ABI of NiftToken Example: For Q2, You don't ...


1

After doing some research I finally have the answers to the questions. 1. What is the abi object inside the contract and what does it do? Is it the same as the one you get when you compile the contract? According to the solidity docs: The Contract Application Binary Interface (ABI) is the standard way to interact with contracts in the Ethereum ecosystem, ...


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