Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
101 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 ...
medvedev1088's user avatar
61 votes
Accepted

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

EDIT May 2021: call{value: amount}("") should now be used for transferring ether (Do not use send or transfer.) Here's an example: (bool success, ) = recipient.call{value:amt}(""); ...
Jakub Wojciechowski's user avatar
18 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}(&...
Lee's user avatar
  • 8,558
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 ...
Dan-Nolan's 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 ...
k06a's user avatar
  • 3,036
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 ...
benjaminion's user avatar
  • 9,287
6 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 ...
Richard Horrocks's user avatar
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....
Daniel Sánchez's user avatar
6 votes

How to send ether to a contract (even if the contract doesn't implement receive or fallback functions)?

The last 2 ways listed for sending balance allow to send balance to a Smart Contract even if it doesn't implement receive and payable fallback functions: You have multiple ways to transfer balance ...
Eric Nordelo Galiano's user avatar
5 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("...
Vikas Mujumdar's user avatar
5 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 ...
AnAllergyToAnalogy's user avatar
5 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 ...
JBrouwer's user avatar
  • 1,062
5 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 ...
wtk219's user avatar
  • 1,241
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 ...
Zakalwe's user avatar
  • 397
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?
eth's user avatar
  • 85.9k
4 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 ...
SCBuergel's user avatar
  • 8,774
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
KNK's user avatar
  • 679
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 ...
Manoj P R's user avatar
  • 458
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....
medvedev1088's user avatar
3 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; ...
Achala Dissanayake's user avatar
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 ...
SCBuergel's user avatar
  • 8,774
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 ...
Alex's user avatar
  • 779
3 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,...
hextet's user avatar
  • 1,583
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 ...
user19510's user avatar
  • 28.1k
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....
Bojan's 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 ...
Mikko Ohtamaa's 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 ...
Lauri Peltonen's 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 ...
Lauri Peltonen's user avatar
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 ...
pabloruiz55's user avatar
  • 7,666
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.
user19510's user avatar
  • 28.1k

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