Cronos EVM Docs
  • Getting Started
    • Getting Started
    • Background
    • Architecture
    • Cronos roadmap
  • FOR USERS
    • 💳Crypto.com Card Top Up
    • 🔥Crypto Wallets
    • 🦊MetaMask Configuration
    • 🦁Brave Wallet
    • 🌉Bridges
      • From the Crypto.com App and Exchange
        • From the Crypto.com App
        • From the Crypto.com Exchange
      • IBC (Cronos POS Chain, other Cosmos chains)
        • Cronos Bridge Web App
      • Independent bridges
      • FAQs for Bridge transfers
      • FAQs for transactions from/to centralized exchanges
    • 🚰Testnet Faucet
    • 💡Tips & FAQs
    • 👮Key Principles for Wallet Security
    • GasTracker
  • FOR DAPP DEVELOPERS
    • 💡Founder FAQs
    • 🏅Hacker's Getting Started Resources
    • 📃Smart Contracts
      • Contract Development on Testnet
      • Contract Deployment and Verification
      • Contract Verification Export: Cronoscan To Cronos Explorer
      • Best Practices
      • Token Contract Addresses
    • 💻dApp Creation
      • Free and commercial RPC endpoints
      • Wallet integrations
      • Web3-wallet
      • JSON-RPC methods
      • Address Conversion
      • Swagger Playground
    • ⚙️Dev Tools & Integrations
      • All dev tools & integrations
      • Account Abstraction
      • Band Protocol
      • Banxa
      • GoldRush
      • Cronos Safe
      • Flair
      • Google Bigquery
      • Moralis
      • Pyth
      • Secret Network
      • SubQuery
      • Witnet
    • Crypto.com AI Agent SDK
  • FOR NODE HOSTS
    • Running nodes
      • Cronos Mainnet
        • Quicksync
        • State-sync
        • Public Node Sync
        • KSYNC
        • The "Huygen" upgrade guide (v0.6.* to v0.7.*)
        • The "v0.7.0-hotfix" upgrade guide (v0.7.* to v0.8.*)
        • The "Galileo" upgrade guide (v0.8.* to v1.0.*)
        • The "Titan" upgrade guide (v1.0.* to v1.1.0)
        • The "v1.2" upgrade guide (v1.1.* to v1.2.0)
        • The "v1.3" upgrade guide (v1.2.* to v1.3.0)
        • The "v1.4" Pallene upgrade guide (v1.3.* to v1.4.1)
        • Patching Unlucky & Duplicate Tx
      • Cronos Testnet
      • Devnet
      • Best Practices
      • Cronosd build with Nix
      • VersionDB
      • MemIAVL
      • Local State Sync
    • Cronosd
  • CRONOS PLAY
    • Introduction
    • Unity Engine
      • Current Version
      • Legacy Version
        • EVM
        • Login Example
        • Custom RPC
        • ERC20
        • ERC721
        • ERC1155
      • Useful Links
    • Unreal Engine
      • Installation and Enabling
      • Working with Blueprint
        • Actors and Blueprint Classes
        • Cronos Configuration
        • Connect Defi Desktop/Onchain Wallet with URI
        • Connect Wallets with QR Code
        • Connect WalletConnect Step by Step
        • WalletConnect 2.0 and Unreal Engine 5: Hello World Example
        • Wallet
        • ERC20
        • ERC721
        • ERC1155
        • Broadcast Transactions
        • Get Tokens or Transactions
      • Working with C++
        • Creating a C++ Project
        • Creating a child DefiWalletCoreActor
        • Querying a contract
        • Customizing Network
      • Demo
    • Cronos Play C++ SDK
    • Crypto.com Pay Integration
    • Cronos Play FAQ
  • Block Explorers
    • Block Explorer and API Keys
    • Cronos Explorer
    • Cronoscan
  • CRONOS CHAIN PROTOCOL
    • Chain ID and Address Format
    • Cronos General FAQ
    • Genesis
    • Modules
      • module_bank
      • module_distribution
      • module_slashing
      • module_feemarket
    • Chain Details
      • List of parameters
      • Technical glossary
      • Protocol Documentation
    • Common IBC Commands
  • Cronos zkEVM
    • Cronos zkEVM
  • Resources
    • Media / brand kit
Powered by GitBook
On this page
  • AddingPlayCppSdkLibrary as dependency module
  • Querying the name of a ERC20 contract
  • Examples
  • Building

Was this helpful?

Edit on GitHub
  1. CRONOS PLAY
  2. Unreal Engine
  3. Working with C++

Querying a contract

After creating MyDefiWalletCoreActor, we can switch to the source code editor and add token querying feature in the actor.

AddingPlayCppSdkLibrary as dependency module

  • Edit CronosPlayDemo.Build.cs, and add PlayCppSdkLibrary, as one of the Dependency Modules.

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "PlayCppSdkLibrary" });

Querying the name of a ERC20 contract

  • Create constructor, and two overridden functions: BeginPlay and Tick

  • In BeginPlay function, call Erc20Namefunction from ADefiWalletCoreActor, and print out logs like below

bool success;
FString output_message;
ADefiWalletCoreActor::Erc20Name("0xf0307093f23311FE6776a7742dB619EB3df62969", name, success, output_message);
FString success_message = success ? "true" : "false";
UE_LOG(LogTemp, Display, TEXT("ERC20 name: %s"), *name);
UE_LOG(LogTemp, Display, TEXT("ERC20 success: %s"), *success_message);
UE_LOG(LogTemp, Display, TEXT("ERC20 output_message: %s"), *output_message);

Examples

MyDefiWalletCoreActor.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "DefiWalletCoreActor.h"
#include "MyDefiWalletCoreActor.generated.h"

/**
 * 
 */
UCLASS()
class CRONOSPLAYDEMO_API AMyDefiWalletCoreActor : public ADefiWalletCoreActor
{
	GENERATED_BODY()

public:
	AMyDefiWalletCoreActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	
};

MyDefiWalletCoreActor.cpp

// Fill out your copyright notice in the Description page of Project Settings.


#include "MyDefiWalletCoreActor.h"

// Sets default values
AMyDefiWalletCoreActor::AMyDefiWalletCoreActor() {
  // Set this actor to call Tick() every frame.  You can turn this off to
  // improve performance if you don't need it.
  PrimaryActorTick.bCanEverTick = true;
}


// Called when the game starts or when spawned
void AMyDefiWalletCoreActor::BeginPlay() {
	Super::BeginPlay();
	FString name;
	bool success;
	FString output_message;
	ADefiWalletCoreActor::Erc20Name("0xf0307093f23311FE6776a7742dB619EB3df62969", name, success, output_message);
	FString success_message = success ? "true" : "false";
	UE_LOG(LogTemp, Display, TEXT("ERC20 name: %s"), *name);
	UE_LOG(LogTemp, Display, TEXT("ERC20 success: %s"), *success_message);
	UE_LOG(LogTemp, Display, TEXT("ERC20 output_message: %s"), *output_message);
}


// Called every frame
void AMyDefiWalletCoreActor::Tick(float DeltaTime) {
	Super::Tick(DeltaTime);
}

Building

Select Development Editor Profile in tool bar > Build > Build Solution (Disable Live Coding on Unreal Editor before building)

PreviousCreating a child DefiWalletCoreActorNextCustomizing Network

Last updated 6 months ago

Was this helpful?