We’re rewarding the question askers & reputations are being recalculated! Read more.
41

You can do this by calling address.balance. To get the contract's balance, just do this.balance. Read the docs. Update: As of Solidity ^0.4.24, you need to do: address(this).balance (Copied from answer by Paul Berg)


29

The main validation constraints in a Bitcoin UTXO system are: every referenced input must be valid and not yet spent the transaction must have a signature matching the owner of the input for every input the total value of the inputs must equal or exceed the total value of the outputs By contrast functionality in an Ethereum account-based system are: a ...


21

Small update from my side: You want to use the following, address(this).balance;


21

geth --fast has an interesting effect: geth cannot provide any information about accounts or contracts until the sync is fully complete. Try querying the balance again after eth.syncing returns false. Why? The "fast" sync looks nearly complete because the reported current block is based on the best header you have. But that doesn't give you any ...


16

It'd probably go something like this: User wants to deposit a token to your exchange If it's the first time the user is depositing that token then this occurs: Generate a new wallet key/pair on the server side Encrypt the private key with a secret/salt only known by the server and store the encrypted private key and public address in your database, along ...


15

Each account has a globally accessible nonce which prevents same-chain replay attacks and double spends. The nonce is the sequence number, which miners check, because a block that has a transaction with an incorrect nonce is an invalid block (other miners won't build on top of it). (The nonce does not protect against cross-chain replay attacks.) Second ...


11

No. You cannot send the entire balance because the fees are deducted from your account's balance, not from the value being sent. To sweep an account you need to send balance-gas*price ETH as the value, and also manually set the gas and gasPrice to ensure that you exactly zero your account. E.g. If you have 5ETH and want to sweep it: A plain account-to-...


11

To check the balance you can do: web3.eth.getBalance(contract.options.address) Or: web3.eth.getBalance("0x045bfe22453a9ca06aff4bdc5d7f5870eba121bd") To transfer balance on a contract without calling a function the contract must have a payable fallback function. http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function


10

A contract can read any balance using address.balance like: _buyer.balance A contract can send its Ether in units of wei using address.send like: seller.send(price) A contract cannot subtract from an arbitrary address. Using send subtracts from the balance of the contract, so if the contract has a balance, it could do: function Execution (address _seller)...


10

As of Solidity ^0.4.24, you need to do: address(this).balance Find an example here.


10

Yes, a contract can have Ether balance without any payable function. There are three ways to do it: 1) selfdestruction. Another contract self destructrs and sends its remaining Ether to your contract 2) Target of mining. Ether rewarded from mining can't be refused. 3) Ether sent to the contract before the contract exists. More details about these ...


9

personally I registered my addresses on https://etherscan.io that provides such a service, by email. If you really want to do it by yourself, the simplest I can think would be to register a cron job that start a getBalance.sh script containing a curl eth_getbalance call. So enter crontab -e and edit the file at the end with : */5 * * * * /home/youruser/...


9

I am not providing an answer here but I am elaborating on a small discussion with @eth which is relevant to the OP's question, and I wanted to share what I have learnt, thanks to @eth and a bit of reading around. The misunderstanding that I had was that all nodes execute code when a transaction invokes that code, and therefore assumed that the result of the ...


9

You can install a block filter and only update balances when a new block arrives. const Web3 = require('web3'); const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); const address = "0x9b...."; let balance = web3.eth.getBalance(address); const filter = web3.eth.filter('latest'); filter.watch((err, res) => { if (err) { ...


9

The issue with your testnet url, https://ropsten.etherscan.io/ is not running eth client. Find below code to connect ropsten node. const testnet = 'https://ropsten.infura.io/'; const walletAddress = '0x8690F1feff62008A396B31c2C3f380bD0Ca6d8b8'; const web3 = new Web3(new Web3.providers.HttpProvider(testnet)); var balance = web3.eth.getBalance(...


8

I'm using the same unmodified script from How many ethers have been drained through the recursive call attacks on The DAO? to calculate the balance of The DAO and it's child DAOs. For a finer categorisation of the different child DAOs, see the latest update from How do I get a refund for my The DAO tokens that was split into a child DAO?. There are several ...


8

Yes. Here Is theDAOVoter Description theDAOVoter v1.0000000000000003 is a little Perl script (~808 lines, 738 source lines) that will allow you to: List The DAO proposals. List your accounts, displaying whether The DAO transfers are blocked due to opened votes and expiry time. List the DAO proposals with a listing of your accounts showing which accounts ...


7

Please refer to address methods documentation. You should prefer to use transfer over send: There are some dangers in using send: The transfer fails if the call stack depth is at 1024 (this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order to make safe Ether transfers, always check the return value of ...


7

The accepted answer is a very good summary of the following wiki: https://github.com/ethereum/wiki/wiki/Design-Rationale#accounts-and-not-utxos See it for further details, including Ethereum's rationale: We have decided that, particularly because we are dealing with dapps containing arbitrary state and code, the benefits of accounts massively ...


7

Apparently, this is not the same inside the anonymous callback function you're passing to getBalance. Try replacing it with a fat arrow function, that binds the outer this value to the inner scope. this.web3.eth.getBalance(this.account, (err, balance) => { this.balance = this.web3.fromWei(balance, "ether") + " ETH" });


6

In order to send Ether, you need to pay a transaction fee of 21k gas (more if you are sending to or from a contract-based wallet). Mist rounds some Ether values, so it is very difficult to send exactly the amount in your wallet. To send roughly the amount you want, just lower the transaction value by 0.0001 ETH or so, or reduce the transaction fee by ...


6

getAllBalances Including TheDAO Tokens Here's a version of getAllBalances that also displays TheDAO tokens. The following shell script works in the Linux and Mac environments where you are already running a geth instance that synch with the Ethereum blockchain. This Unix shell script is based on the checkAllBalances() script from Ethereum Frontier Guide - ...


6

The Baddies joined into the Split Proposal #59 where they were not the curator. From this split, the Baddies created a number of split proposals where the Split Proposal #59.10 was used to split out the attacked funds into a split where the attacker was the curator. The Baddies have now created the Non-Split Proposals #59.10.1 and #59.10.2 where the funds ...


6

The related question linked in comments by Richard Horrocks answers the question pretty well IMO. Here's what the Ethereum yellowpaper has to say about this (search for balance, it's hit number 2 ATM for me): 4.1. World State. [...] is a mapping between addresses [...] and account states. Though not stored on the blockchain, it is assumed that the ...


5

Basic answer is no ! Anytime you want to perform a transaction, you'll have to pay a fee for the computation involved in validating and mining your tx. If you do not have enough gas, you cannot send your tx to the network. In your example, send "all" and the receiver will get 5 minus fees.


5

getBalance With A Block Number You can pass in the block number as part of the parameter. Here is Kraken's address: 0x2910543af39aba0cd09dbb2d50200b3e800a63d2. Let's check what the latest block number is: > eth.blockNumber 1456129 Let's get the latest balance for Kraken: > eth.getBalance("0x2910543af39aba0cd09dbb2d50200b3e800a63d2", "latest") 4....


5

Did this account generate Ether out of thin air? No. Ethereum isn't broken, and neither are ENS or Etherscan. Although Etherscan could be clearer about what's happening here. So how do you get the real balance? If you click into the most recent transaction issued by the account (the one with 0 outbound value), you see this: Sorry it's awkwardly clipped. ...


5

As previously mentioned it doesn't appear possible using etherscan. But it's possible using the (free) ethexplorer.io API. The format is: http://api.ethplorer.io/getAddressInfo/[YOUR_ADDRESS]?apiKey=freekey For example: http://api.ethplorer.io/getAddressInfo/0x32Be343B94f860124dC4fEe278FDCBD38C102D88?apiKey=freekey API documentation is here: https://...


4

getAllBalances For Ethers Only The following shell script works in the Linux and Mac environments where you are already running a geth instance that synch with the Ethereum blockchain. This Unix shell script uses the checkAllBalances() script from Ethereum Frontier Guide - Listing accounts and checking balances. You can customise the geth attach command ...


4

You have one vote per account, but your one vote has the weighting of your account's token balance. And as @Nick Johnson commented below, this is functionally equivalent to having one vote per token. If you vote Yea, the balance of your token account is added to the Yea accumulator. If you vote Nay, the balance of your token account is added to the Nay ...


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