If I have a contract like below:

contract wallet{

   mapping (address => uint) balances
   function send(){...}


and I deploy this contract on the ethereum.

When I want to query the balances for example check the balance of Alice, is there any api to do this query directly like SQL.


1 Answer 1


There is no query api like SQL, you can invoke contract method to finish it. This is a simple contract, you can get balance by name

pragma solidity ^0.4.0;

contract Wallet {

    mapping (address => uint) balance;

    function desosite() payable{
        balance[msg.sender] += msg.value;

    function getBlance() constant returns (uint) {
        return balance[msg.sender];


Hope it helps~

  • Can I call the "getbalance()" to get data outside the etherum? Or it can only be called by another contract?
    – njuyuanrui
    Commented Aug 9, 2017 at 1:33
  • If you had deployed this contract on private chain, call your_contract_name.getBalance(from:eth.coinbase) Commented Aug 9, 2017 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.