New answers tagged

1

The guide is slightly off, as if there is no data in your transaction and you send ether in it, the EVM will first try to call a function receive() payable {...} if you have it. This is a function that handles receiving the ether, but if you want you can omit it and then the EVM will call the fallback function. The fallback function is what happens when the ...


1

You should first cast the contract to a certain type before accessing its methods. In this case, you need to query the balanceOf an ERC721, so we'll use the IERC721 interface: require(IERC721(0x..).balanceOf(msg.sender) >= 1, "..."); P.S. To access IERC721 you can import the OZ implementation, which you're probably already doing.


0

I asked basically the same question on StackOverflow but for python, below is my solidity adaptation using this answer: // SPDX-License-Identifier: GPL-3.0 contract TwosComplement { function twos_comp_to_sign_mag(int8 value) external pure returns(int8) { int8 mask = 2**7 - 1; // 0111_1111 if (value < 0) { value = ...


0

ABI (Application Binary Interface) in the context of computer science is an interface between two program modules, often between operating systems and user programs. EVM (Ethereum Virtual Machine) is the core component of the Ethereum network, and smart contract is pieces of code stored on the Ethereum blockchain which are executed on EVM. Smart contracts ...


3

Using a simple declaration inside a function such as : uint posptr; This won't be possible, as per my understanding, those variables only live on the stack and don't have a definitive usable memory address (Stack and Memory are separated in the EVM as you can see here for go-ethereum) However, I suppose that you could wrap your variable into a struct that ...


0

By default, all storage locations have zero value on the EVM. So when you change a slot from zero to non-zero, the overall size of the state increases. This means, all the nodes have to allocate extra storage to accommodate for the new slot you created. However, when you change a non-zero to another non-zero, it doesn't increase the overall size of the EVM ...


5

The maximum amount of token that a ERC-20 contract can mind (according to the specification) is the max of uint256, which is (2 ** 256)-1 ≈ 10 ** 77. And the decimal variable merely mentions the number of decimal places to be used while displaying the amount on a UI. Theoretically, you could use any decimal. As long as the decimal is less than 77, you'll ...


1

Are these two different concepts? Even though we can't predict the result beforehand, being deterministic means that for the same starting conditions, and given the same inputs, the same result will occur, even if that result is a smart contract running forever†. It will run forever in the same way - following the same execution path - on each node in the ...


0

EVM is deterministic. To exclude "eternal" calculations, a gas mechanism is used - a gas limit per transaction is set in the network. If it is exceeded, the transaction is rejected.


1

This is what I would do: I would run a local fork of mainnet using hardhat node provider_url and do the transaction there, while capturing the events and reading the state changes that resulted afterwards.


1

The Ethereum Virtual Machine executes the bytecode that is present on the Ethereum blockchain. Each bytecode has a specific gas price that is defined in the consesus specification and can be looked up in the Ethereum yellow paper (at page 27). When you write Solidity code then solc (the Solidity compiler) will convert this code into YUL, an intermediate ...


2

Your "opcode tool" link leads to a completely different address (0x9e1b57fc92eba6434251a8458811c32690f32c45). If you check opcodes for your original address, you'll see they're the same: 0xdac17f958d2ee523a2206206994597c13d831ec7 (code) PUSH1 0x60 PUSH1 0x40 MSTORE PUSH1 0x04 CALLDATASIZE LT PUSH2 0x0196 JUMPI PUSH1 0x00 CALLDATALOAD PUSH29 ...


0

Failed transactions are also part of the Ethereum blockchain. This is because even for failed transactions a gas fee is paid. This fee payment is a state change and needs to be kept track of in the blockchain. If a transaction would fail because the fee payment cannot be made or the nonce is not in order anymore, then the transaction will not be included in ...


0

It does not work with time, it works with block.timestamp which is a Unix time stamp. for example at block number XXXXXX, something happens. Then secondly, it does not automatically execute, its more of a requirement that checks. So a user will have to click to withdraw duns, then the blockchain checks if the time is met, if not...transaction will fail. ...


0

Writing multiple times to a specific storage slot is cheaper, but not free. The current state is defined by EIP-2929 Edit: Since you asked about temporary or so called transient storage. There is an EIP that is aimed towards this: EIP-1153


0

As of jan 2022, there is no EVM compiler that supports generator functions. Fingers crossed for the future


0

Transfering ETH (which is done by setting msg.value) is a state change. When your transaction reverts any state change is also reverted. This means the value "stays" in the original wallet. As you mentioned the only change that is done to the blockchain is the fee payment. Note: If an internal transaction reverts, it doesn't mean that the whole ...


0

Your gas price is extremely low. You can query the gas price with web3.eth.gasPrice(), when I did this I got 2000000000. As your 35000 is very low it will take a long time (or potentially never) for a miner to pick up this transaction.


0

A full answer to this question should detail the difference between CREATE, CREATE2 opcodes, which are the two opcodes in the EVM for creating new contracts; it should be possible to do this using either as long as for CREATE you use the same keypair across all chains, and have the same nonce on all chains. This article also details how to use CREATE2 for ...


0

There's an even simpler implementation called Burner Wallets for Ethereum that doesn't even store a password hash: see https://burnerwallet.co/ -- it seems so far that there haven't been any attacks. I wouldn't use just password hashes, as then you are vulnerable to a rainbow attack if localstorage is compromised (and that seems like the whole point of your ...


0

The state root saved in a block is the result after processing all the transaction in the block. From Yellow Paper section 4.3 "The Block" stateRoot: The Keccak 256-bit hash of the root node of the state trie, after all transactions are executed and finalisations applied; formally Hr.


1

An unconventional of EXTCODECOPY is to use a deployed contract as the "storage" of another contract, as is is done by this library: https://github.com/0xsequence/sstore2 The rationale is that writing/reading data in the contract code region can become cheaper than writing/reading data in the storage region. Cheaper storage reads (vs SLOAD) after ...


Top 50 recent answers are included