Read From Blockchain
Indexer & the Wallet
The Indexer is tied nicely with the wallet to allow for ease of use. One thing to note is the NetworkId you set with your wallet is the one that will be used with the Indexer. The default network we set is 137 (Polygon Mainnet). See the list of network ids supported by Sequence here.
Using Indexer
If you want to use our Indexer APIs when a user has not signed in with Sequence, create an instance of the UIndexer class.
// Define success and failure callbacks
const TSuccessCallback<FEtherBalance> SuccessCallback = [=](const FEtherBalance& etherBalance) { };
const FFailureCallback GenericFailure = [=](const FSequenceError& Error) { };
// Create an instance of UIndexer with example call
const UIndexer* Indexer = NewObject<UIndexer>();
Indexer->GetEtherBalance(137, "0x0...", SuccessCallback, FailureCallback);
Ping
const TSuccessCallback<bool> GenericSuccess = [=](const bool bSuccess)
{
//Ping response is in bSuccess
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//Ping failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
Wallet->Ping(GenericSuccess, GenericFailure);
}
Version
const TSuccessCallback<FVersion> GenericSuccess = [=](const FVersion& version)
{
//Response contained in FVersion
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//Version Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
Wallet->Version(GenericSuccess, GenericFailure);
}
RunTimeStatus
const TSuccessCallback<FRuntimeStatus> GenericSuccess = [=](const FRuntimeStatus& runTimeStatus)
{
//Response is in FRunTimeStatus
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//RunTimeStatus Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
Wallet->RunTimeStatus(GenericSuccess, GenericFailure);
}
GetChainID
const TSuccessCallback<int64> GenericSuccess = [=](const int64 chainID)
{
//Response in int64
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetChainID Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
Wallet->GetChainID(GenericSuccess, GenericFailure);
}
Get Ether Balance
Use the Indexer API to retrieve the Ether balance for a specified wallet address, such as the local user's address.
// Define success and failure callbacks
const TSuccessCallback<FEtherBalance> GenericSuccess = [=](const FEtherBalance& etherBalance) { };
const FFailureCallback GenericFailure = [=](const FSequenceError& Error) { };
// Get a reference of the user's current wallet session.
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
// Example Indexer call
USequenceWallet * Wallet = WalletOptional.GetValue();
Wallet->GetEtherBalance(Wallet->GetWalletAddress(), GenericSuccess, GenericFailure);
}
GetTokenBalances
const TSuccessCallback<FGetTokenBalancesReturn> GenericSuccess = [=](const FGetTokenBalancesReturn& tokenBalances)
{
//Response in FGetTokenBalancesReturn
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetTokenBalances Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
FGetTokenBalancesArgs args;
args.accountAddress = Wallet->GetWalletAddress();
args.includeMetaData = true;
Wallet->GetTokenBalances(args, GenericSuccess, GenericFailure);
}
GetTokenSupplies
const TSuccessCallback<FGetTokenSuppliesReturn> GenericSuccess = [=](const FGetTokenSuppliesReturn& tokenSupplies)
{
//Response is in FGetTokenSuppliesReturn
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetTokenSupplies Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
FGetTokenSuppliesArgs args;
args.contractAddress = "0x01";//Testing Contract Address in hex with leading 0x
args.includeMetaData = true;
Wallet->GetTokenSupplies(args, GenericSuccess, GenericFailure);
}
GetTokenSuppliesMap
const TSuccessCallback<FGetTokenSuppliesMapReturn> GenericSuccess = [=](const FGetTokenSuppliesMapReturn& tokenSuppliesMap)
{
//Response is in FGetTokenSuppliesMapReturn
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetTokenSuppliesMap Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
TMap<FString, FTokenList> tokenMap;
const TPair<FString,FTokenList> item;
tokenMap.Add(item);
FGetTokenSuppliesMapArgs args;
args.includeMetaData = true;
args.tokenMap = tokenMap;
Wallet->GetTokenSuppliesMap(args, GenericSuccess, GenericFailure);
}
GetBalanceUpdates
const TSuccessCallback<FGetBalanceUpdatesReturn> GenericSuccess = [=](const FGetBalanceUpdatesReturn& balanceUpdates)
{
//Response in FGetBalanceUpdatesReturn
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetBalanceUpdates Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
FGetBalanceUpdatesArgs args;
args.contractAddress = "0x0E0f9d1c4BeF9f0B8a2D9D4c09529F260C7758A2";
args.page.page = 10;
args.page.more = true;
Wallet->GetBalanceUpdates(args, GenericSuccess, GenericFailure);
}
GetTransactionHistory
const TSuccessCallback<FGetTransactionHistoryReturn> GenericSuccess = [=](const FGetTransactionHistoryReturn& transactionHistory)
{
//Response is in FGetTransactionHistoryReturn
};
const FFailureCallback GenericFailure = [=](const FSequenceError& Error)
{
//GetTransactionHistory Failure
};
const TOptional<USequenceWallet*> WalletOptional = USequenceWallet::Get();
if (WalletOptional.IsSet() && WalletOptional.GetValue())
{
USequenceWallet * Wallet = WalletOptional.GetValue();
FGetTransactionHistoryArgs args;
args.filter.accountAddress = Wallet->GetWalletAddress();
args.includeMetaData = true;
args.page.page = 0;
args.page.more = true;
Wallet->GetTransactionHistory(args, GenericSuccess, GenericFailure);
}