0

How can I verify within a smart contract that an account is a proxy? I know that there is a function is_account, which verifies that a name is an existing account. Is there a way to check if an account is a proxy? Such as a function like is_proxy?

1
  • Proxy in what sense? Are you referring to a voting proxy?
    – Ami Heines
    Jul 14, 2019 at 8:08

1 Answer 1

2

There's no provided is_proxy method, but proxy information is stored in multi_index in eosio account, you can query that from your contract. The next code block is an example of is_proxy implementation.

/**
 * @file proxy.hpp
 */
#pragma once

#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>

namespace eosio {

   constexpr name system_account{"eosio"_n};

   struct voter_info {
      name                owner;
      name                proxy;
      std::vector<name>   producers;
      int64_t             staked = 0;
      double              last_vote_weight = 0;
      double              proxied_vote_weight= 0;
      bool                is_proxy = 0;
      uint32_t            flags1 = 0;
      uint32_t            reserved2 = 0;
      eosio::asset        reserved3;

      uint64_t primary_key()const { return owner.value; }

      EOSLIB_SERIALIZE( voter_info, (owner)(proxy)(producers)(staked)(last_vote_weight)(proxied_vote_weight)(is_proxy)(flags1)(reserved2)(reserved3) )
   };

   typedef eosio::multi_index< "voters"_n, voter_info >  voters_table;

   bool is_proxy(name name) {
      voters_table _voters(system_account, system_account.value);

      auto it = _voters.find(name.value);
      return it != _voters.end() && it->is_proxy;
   }

} /// namespace eosio

Your Answer

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

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