Shane Fontaine
  • Member for 3 years, 5 months
  • Last seen this week
When should I use calldata and when should I use memory?
Accepted answer
87 votes

memory and calldata (as well as storage) are keywords that define the data area where a variable is stored. To answer your question directly, memory should be used when declaring variables (both ...

View answer
What are the virtual and override keywords in Solidity?
Accepted answer
39 votes

As of Solidity 0.6.0, the keywords virtual and override are available natively in Solidity for function overriding. The purpose of these keywords is to be more explicit when overriding a function. ...

View answer
What is the receive keyword in solidity?
Accepted answer
33 votes

TL;DR receive is a new keyword in Solidity 0.6.x that is used as a fallback function that is only able to receive ether. receive() external payable — for empty calldata (and any value) fallback() ...

View answer
Difference between Ganache and Truffle
Accepted answer
29 votes

Ganache allows you to create a private Ethereum blockchain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all ...

View answer
What is the difference between bytecode, init code, deployed bytedcode, creation bytecode, and runtime bytecode?
Accepted answer
26 votes

I wrote an article that goes over this information in depth. I will summarize it here. tl;dr - There are only two types of bytecode on Ethereum but five different names to describe them. Creation ...

View answer
What is the immutable keyword in Solidity?
Accepted answer
16 votes

The immutable keyword was added to Solidity in 0.6.5. State variables can be marked immutable which causes them to be read-only, but assignable in the constructor. The value will be stored directly ...

View answer
Is it possible to deploy a contract using create2 in Solidity?
Accepted answer
14 votes

Yes. Solidity version 0.6.2 introduced a high-level way to use the create2 opcode. From the release docs: When creating a contract, you can specify the salt as a "function call option": new ...

View answer
Is it possible to perform a try-catch in Solidity?
Accepted answer
14 votes

Solidity 0.6.0 and Greater (Updated 2020) As of Solidity 0.6.0, there is try-catch functionality built into the language. The syntax is similar to existing languages, however functionality is limited ...

View answer
Setup Ganache with Metamask. What and where is a Chain ID?
14 votes

From the ganache-cli docs: --chainId: Specify the Chain ID ganache-cli will use for eth_chainId RPC and the CHAINID opcode. For legacy reasons, the default is currently 1337 for eth_chainId RPC and 1 ...

View answer
How can I slice bytes, strings, and arrays in Solidity?
Accepted answer
14 votes

Solidity 0.6.0 and Greater (Updated 2020) As of Solidity 0.6.0, there is array slice functionality built into Solidity. The syntax is similar to existing languages in that the array takes the ...

View answer
What is the difference between the constant and immutable keywords in Solidity?
Accepted answer
9 votes

Both immutable and constant are keywords that can be used on state variables to restrict modifications to their state. The difference is that constant variables can never be changed after compilation, ...

View answer
Execute transaction Approve directly against contract address (without ABI)
Accepted answer
9 votes

You will need the ABI. The .methods is an attribute of the contract instance, which you get by using the ABI. If you are using ethers.js, you can use a shorthand ABI to achieve the same goal: let ...

View answer
What's the vulnerability in my contract?
Accepted answer
8 votes

It sounds like you are being front run. This means that a bot is watching you send a transaction, reading the input (specifically, _answer), and submitting a transaction with the correct answer but a ...

View answer
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
8 votes

Your friend simply edited the HTML and changed the TimeStamp, To, and Value on that page. You can tell this because all of the other stats on the page are correct, with the exception of the items ...

View answer
Max/min values of standard data types
Accepted answer
7 votes

Updated 2020 Solidity 0.6.8 introduced min and max keywords that can now natively tell you the min and max of an expected type. From the release page: Implemented type(T).min and type(T).max for ...

View answer
Status of ABIEncoderV2 now
Accepted answer
7 votes

Update 2020 (#2) As of Solidity 0.6.0, ABIEncoderV2 is no longer experimental. Update 2020 (#1) An update from the Solidity team reads: We are almost finished with implementing breaking changes and ...

View answer
Issue with New version of Metamask: Remix cannot detect the Metamask address
7 votes

The reason it is not being read is because this version of Metamask enables privacy mode by default. What this does is require you to approve the application to view/use your wallets on Metamask. For ...

View answer
What happens if you transfer ether and no miner is running?
Accepted answer
7 votes

The transaction will simply sit in the txpool until a miner picks it up and includes it in a block. If there is nobody mining, the blockchain will simply not produce any more blocks and thus not ...

View answer
Can we see events in ganache?
6 votes

Update 2020 Events are now available in the 2.1.0 release. Original Answer It is not currently possible, but is on the roadmap.

View answer
Truffle test, how to get address(0)?
Accepted answer
6 votes

You can simply use 0, or 0x0000000000000000000000000000000000000000. address(0) in Solidity is equivalent to 0x0000000000000000000000000000000000000000.

View answer
How is it possible for 0x0000000000000000000000000000000000000000 to send out ERC-20 tokens?
Accepted answer
6 votes

Per the ERC20 standard, newly created ERC20 tokens are sent from 0x0000000000000000000000000000000000000000 to the address they are meant to be sent to. It was done as a way of logging and to avoid ...

View answer
Etherscan api for Ropsten testnet
Accepted answer
5 votes

According to the docs, you must simply append "-ropsten" to the subdomain. Your URL should look as follows: https://api-ropsten.etherscan.io/api?module=account&action=tokenbalance&...

View answer
How to get timestamp of an event log in emitted event from smart contract
Accepted answer
5 votes

You can do this by checking the timestamp of the block that the event was included in. For something like web3.js, you can use getBlock: web3.eth.getBlock(blockHashOrBlockNumber [, ...

View answer
Is there a way to simulate running a transaction on a geth instance?
5 votes

You can do this by forking the network and performing the transaction on your forked (private) chain. To do this, have an instance of the network on port 8545 and run the following ganache-cli ...

View answer
Encoded input params
Accepted answer
5 votes

Transactions are encoded based on the Contract ABI Specification. It is hard to get through, but these docs have all the answers to your question. The transaction in question is passing in two ...

View answer
Invalid implicit conversion from uint256 to bytes memory requested
Accepted answer
5 votes

You are getting this error because you are trying to take the keccack256 hash of a uint, which you cannot do, according to the docs. What you must do instead is convert the uint to a bytes. The code ...

View answer
Weird error 'The method eth_accounts does not exist/is not available'
Accepted answer
4 votes

You must specify the parameters using --rpcapi="db,eth,net,web3,personal" Source

View answer
What is the purpose of extcodecopy?
Accepted answer
4 votes

It is used to check and compare a contract's bytecode, similar to comparing a known hash of a download file to confirm its legitimacy. The best description of why it is useful (and suggestions as to ...

View answer
SLOAD costs 800 gas - how is it possible?
Accepted answer
4 votes

EIP-1884 changed the cost of an SLOAD from 200 to 800, which explains why you are seeing exactly 600 more than expected. It looks like the yellow paper has not been updated to reflect this change. ...

View answer
i am new to this, can someone steal my erc20 token with the Function approve()
Accepted answer
4 votes

Yes, technically the _spender can take up to 999999999999999000000000000000000 of your tokens. Unfortunately, this is common practice, as it makes token transactions of this nature more user-friendly. ...

View answer
1
2 3 4 5
12