93 votes

<address>.send vs <address>.transfer best practice usage?

address.transfer() throws on failure forwards 2,300 gas stipend (not adjustable), safe against reentrancy should be used in most cases as it's the safest way to send ether address.send() returns ...
user avatar
  • 10.2k
51 votes
Accepted

<address>.send vs <address>.transfer best practice usage?

Both send and transfer are considered to be a safe way to move funds as they have a gas stipend of 2300. If you are curious about the reasons for adding a transfer you may follow an original ...
user avatar
16 votes

Using ".value(...)" is deprecated. Use "{value: ...}" instead

With respect to the ".value(...)" is deprecated. Use "{value: ...}" warning: You can use the following pattern to remove the warning: (bool success, ) = recipient.call{value:amt}(&...
user avatar
  • 7,814
10 votes

safeTransferFrom is undefined in buidler test

Ran into this myself as well. Are you using ethers.js with Buidler? The safeTransferFrom method is overloaded and generally with ethers.js the bare definition is the default method used. If you run ...
user avatar
  • 261
8 votes
Accepted

address payable type - store address and send later using Solidity 0.5.0

UPDATE: Solidity 0.6.x now have explicit conversions to payable: payable(userAddress) And for smart contracts: payable(address(smartContract)) Old answer for Solidity 0.5.x: Here is how to cast ...
user avatar
  • 2,096
6 votes
Accepted

Why there are 'OUT' token transfers from the zero (0x00...) address?

ERC20 token transactions don't have to follow the same rules as Ether transactions. What the list of token transfers for address 0x00 is showing you is a list of Transfer events that have been raised ...
user avatar
  • 8,622
6 votes

Cannot tranfer() ETH to Gnosis Safe

This is explanied here: https://help.gnosis-safe.io/en/articles/5249851-why-can-t-i-transfer-eth-from-a-contract-into-a-safe You can also check further information in this post https://consensys....
user avatar
5 votes

0x0000000000000000000000000000000000000000 address behaviour

ETH + ERC20 tokens sent there are burnt Effectively. Unless someone generates the private key, in which case they'll take ownership of those funds. Note that you could pick any other unused address ...
user avatar
5 votes
Accepted

Regular address turns into a contract after receiving a transfer?

Looks like the answer to your question is CREATE2. This is an EVM opcode that was created to allow contracts to be created deterministically, (other people use the term 'counterfactually') It's a ...
user avatar
  • 399
4 votes

<address>.send vs <address>.transfer best practice usage?

Very good answers above but please note the change in syntax in the latest version of Solidity. From Solidity Docs: address(nameReg).call{gas: 1000000, value: 1 ether}(abi.encodeWithSignature("...
user avatar
4 votes

<address>.send vs <address>.transfer best practice usage?

EDIT Dec 2019: call.value()() should now be used for transferring ether. (Do not use send or transfer.) See: Is transfer() still safe after the Istanbul update?
user avatar
  • 77.9k
4 votes
Accepted

Gas cost tests: Sending a transaction to a new address is more expensive?

Yes this is true. If you read the Ethereum Yellow paper you can see in Appendix H that you have to pay extra gas if you send Ether to a new account. This is to discourage addresses sending a load of ...
user avatar
  • 972
4 votes

Solidity: "send" and "transfer" are only available for objects of type "address payable", not "address"

You need to define the function as: function unbond(address payable wallet, bytes32 specifier, uint quantity) internal
user avatar
  • 609
3 votes
Accepted

Transaction revert in Remix

Problem: You are trying to send Ethers with the command receiver.transfer(amount); and specifying the amount as a parameter. Since your contract do not have enough ether balance it reverts the ...
user avatar
  • 438
3 votes

Explain working of address.send function in solidity

send() will be deprecated in the future in favor of transfer(). You can read about the differences in this answer <address>.send vs <address>.transfer best practice usage? address....
user avatar
  • 10.2k
3 votes

How to monitor all your addresses and send payments out immediately to a main address

You have basically two different approaches: do the distribution via smart contract wallet or have a client watch your private-key controlled account and then initiate a payment In detail, for 1 you ...
user avatar
  • 8,064
3 votes
Accepted

Transferring ethers using a "for loop" in a smart contract

HIGHLY recommended that you require users to pull their funds instead of push them to the users with a for-loop. A lot harder to implement with a large amount of users, need to run though the loop ...
user avatar
  • 729
3 votes
Accepted

Does `address.transfer` forward all gas (suceptible to re-entrancy)?

I setup a minimal test example that you can find on https://gist.github.com/anonymous/07d4714c27dbf1af0e5cb16c9f833353 pragma solidity ^0.4.11; contract Test { Receiver myR; function ...
user avatar
  • 8,064
3 votes
Accepted

How to send Ether to a contract successfully?

A contract can't forcefully extract ETH from a wallet address, if you want to pay Ether into a contract, you must set the "Value" of the transaction when calling a function (or just send ETH to the ...
user avatar
3 votes

Who pays transaction fee ? Payer or Recipient of the ETH?

The payer of the transaction pays for the gas cost. There is currently no option of making the recipient pay for the ether. You can do a gas estimate and deduct the amount of ether the recipient would ...
user avatar
  • 1,161
3 votes
Accepted

UPDATED : How to determine "payer address" in "address.transfer(amount)"?

This line: recipient.transfer(amount); transfers amount wei from the contract's balance to the recipient. This line: recipient = msg.sender; means that the recipient is the account that called the ...
user avatar
  • 26.2k
3 votes

Regular address turns into a contract after receiving a transfer?

CREATE2 is very cool, I was one of the engineers that worked on this project at Coinbase Commerce. You can read more about the implementation and our approach at the following blogpost https://blog....
user avatar
  • 35
3 votes

How to forward tokens without paying a gas

There are no "wallet aliases" in Ethereum. Sounds like you came up with this term yourself. It is not possible to avoid paying gas and somebody needs to pay for it. Ethereum network is ...
user avatar
3 votes
Accepted

Request a transaction amount in a function

The contract can't prompt the user for any input. It has to be the frontend code which asks the user for input. So in your frontend you need to ask the user to input the amount of Ether to send and ...
user avatar
3 votes
Accepted

Solidity: ERC-20 TransferFrom reverts after approval

Your problem is that you can't do approve and transferFrom in the same transaction. The approve has to be performed by the token owner. So basically the token owner calls the token contract's approve ...
user avatar
2 votes

How to create unique addresses for custom ERC20 tokens

tl;dr contract addresses are always unique as they are determined based off the address creating the account, and the nonce of that address. This means that no two contracts will have the same address,...
user avatar
  • 1,513
2 votes

How to create unique addresses for custom ERC20 tokens

I assume you mean being able to create vanity addresses that start with some characters of your choosing. If it's that so, you can check this tool: https://github.com/MyEtherWallet/VanityEth ** I ...
user avatar
  • 7,216
2 votes

what happens if I try to send my gdax btc to an eth address?

I'm not sure this kind of mistake is possible. Bitcoin addresses are represented by ~34-character base-58 strings, while Ethereum addresses are represented by 40-character base-16 strings.
user avatar
  • 26.2k
2 votes
Accepted

Cannot transfer ERC20 token, "Bad instruction" error

Figured this out. The problem was that I had multiple contracts in the .sol file, where the actual main contract was being assembled (inherited?) from several smaller ones. This tutorial1_contract....
user avatar
  • 183
2 votes
Accepted

Search in Address[] if exist the same address sender

As i feel easy way is to keep a mapping that would store Boolean value true for already in addresses. Contract Hello { address[] internal Pool; mapping (address => boolean) private oldUsers; ...
user avatar

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