How do we accomplish this on EOSIO?
In Ethereum we get the reference of another contract using the contract address, what about for EOSIO?
Can anyone provide a sample code for this?
Would like to pull the balance from another smart contract.
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communityDeclare the following struct in your contract
struct account {
asset balance;
uint64_t primary_key()const { return balance.symbol.name(); }
};
typedef eosio::multi_index<N(accounts), account> accounts;
Write the following in one of the action of contract. It is reading the accounts table of eosio.token contract and printing the balance of "user111"
symbol_type symbol(S(4,SYS));
accounts fromAcc(N(eosio.token),N(user111));
const auto& myAcc = fromAcc.get(symbol.name());
myAcc.balance.print();
#include <eosiolib/eosio.token.hpp>
you can just use that last section of your post, without struct account...
and typedef eosio::multi_index...
? Cheers, good answer
unable to find key
Aug 26, 2018 at 18:53
By querying eosio.token's accounts
table.
./cleos/cleos -u http://api.eosnewyork.io:80 get table eosio.token <account-name> accounts
BTW, this returns []
if the account is never transferred any token (like EOS).
Use userres
table to get account info.
./cleos/cleos -u http://api.eosnewyork.io:80 get table eosio <account-name> userres