LogoLogo
PAO DocsInfrastructure DocsDeveloper DocsPeerplays.com
  • Introduction to Peerplays
  • Concepts
    • Decentralization
    • Consensus Mechanisms Compared
  • Technology
    • Peerplays Technical Summary
    • Intro to Peerplays Tokens
    • Intro to Peerplays Liquidity Pools
      • Service Infrastructure Pools
    • Staking (PowerUp) in Peerplays
    • Gamified User Namespaces and Subject Matter Expert Committees
    • Peer-to-Peer Autonomous Organizations: Flow Diagram
    • Gamified Proof of Stake (GPOS)
      • Wallet User Guide
        • GPOS Panel
        • GPOS Landing Page
        • Power Up
        • Power Down
        • Vote
        • Thank you for voting!
      • FAQ
        • General
        • GPOS Panel
        • Power Up & Power Down
        • Voting
        • Participation Rewards
    • Sidechain Operator Nodes (SONs)
      • New to SONs?
        • What are Sidechain Operating Nodes?
        • How do SONs Work?
        • Why are SONs important?
        • How do SONs impact me?
        • SON Fees & Performance Requirements
        • Peerplays SONs
      • FAQ
      • Running a SON Node
    • NFTs and Marketplace
      • NFT marketplace in Python
      • NFT Operations in Python
      • NFT, Marketplace, HRP, and RBAC related Commands/Use Cases
      • NFT command reference
    • Peerplays DEX
      • User Guide
        • Account Creation
        • Dashboard
          • Bitcoin Transaction
        • Market Activity
        • Peerplays Blocks
        • Settings
        • Wallet
        • Profile
        • GPOS - Voting
        • Logout
  • Witnesses
    • What is a Peerplays Witness?
    • Becoming a Peerplays Witness
    • Hardware Requirements
    • Installation Guides
  • Bookie Oracle Suite (BOS)
    • Introduction to BOS
    • BOS Installation
    • BookieSports
    • Manual Intervention Tool (MINT)
  • Data Proxies
    • Introduction to Data Proxies
    • How Data Proxies Work
    • Data Proxy Set Up
  • Couch Potato
    • Introduction
    • Installation
    • User Guide
  • Random Number Generator (RNG)
    • RNG Technical Summary
    • RNG API
  • API
    • Peerplays Core API
      • Popular API Calls
      • Account History API
      • Asset API
      • Block API
      • Crypto API
      • Database API
      • Network Broadcast API
      • Network Nodes API
      • Orders API
    • Wallet API
      • Account Calls
      • Asset Calls
      • Blockchain Inspection
      • General Calls
      • Governance
      • Privacy Mode
      • Trading Calls
      • Transaction Builder
      • Wallet Calls
    • Bookie API
      • General
      • Tournaments
      • Listeners
    • Python Peerplays
      • Installation
      • Creating the wallet
      • Creating an Account
      • NFT
      • Market Place
      • HRP / RBAC
  • Connecting Elasticsearch to a blockchain node
  • GitLab
    • GitLab Ticket Templates
    • Labels
    • Time Tracking
  • Other Documentation
    • Peerplays Home
    • Infrastructure Docs
    • Developer Docs
    • Site Reliability Engineering
  • Known Issues
    • Peerplays Disaster Recovery Plan
    • Sept 2021 Mainnet Outage - Postmortem Report
  • Kickstart Guide
    • Peerplays Developer
  • Risk Register
    • Introduction
      • Bunker Issue
        • DDOS Attack
        • Hypervisor Compromised
        • Power and Backup Failure
        • Crypto Restriction
      • Core-Block Issue
        • Expensive Servers
        • Witness node - Not reachable
        • Witnesses get DDOS'd
        • Bad Actor infiltrate witness/SONs
      • Credential Security
        • NEX Open Source Vulnerabilities
        • Keyloggers, access to NEX deployment
        • Password manager hacked
        • SONs active keys exposed in configuration
    • Glossary
  • Operation Cost Estimation
    • Project Operations
    • Cost Estimation
Powered by GitBook
On this page
  • Overview
  • API Calls
  • list_account_balances
  • transfer
  • transfer2
  • get_account_history
  • get_object
  • get_asset
Export as PDF
  1. API
  2. Peerplays Core API

Popular API Calls

Overview

Some of the most interesting API calls for exchanges and gateways are listed in this document.

We will now take a look at some sample outputs for some of the API calls.

API Calls

list_account_balances

List the balances of an account. Each account can have multiple balances, one for each type of asset owned by that account. The returned list will only contain assets for which the account has a nonzero balance.

vector<asset> graphene::wallet::wallet_api::list_account_balances(
    const string &id)
  • id: the name or id of the account whose balances you want

A list of the given account’s balances.

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.list_account_balances("dan")
print(json.dumps(res,indent=4))
[
    {
        "asset_id": "1.3.0",
        "amount": "331104701530"
    },
    {
        "asset_id": "1.3.511",
        "amount": 3844848635
    },
    {
        "asset_id": "1.3.427",
        "amount": 8638
    },
    {
        "asset_id": "1.3.536",
        "amount": 31957981
    }
]

transfer

Transfer an amount from one account to another.

signed_transaction graphene::wallet::wallet_api::transfer(
    string from, 
    string to, 
    string amount, 
    string asset_symbol, 
    string memo, 
    bool broadcast = false)
  • from: the name or id of the account sending the funds

  • to: the name or id of the account receiving the funds

  • amount: the amount to send (in nominal units to send half of a BTS, specify 0.5)

  • asset_symbol: the symbol or id of the asset to send

  • memo: a memo to attach to the transaction. The memo will be encrypted in the transaction and readable for the receiver. There is no length limit other than the limit imposed by maximum transaction size, but transaction increase with transaction size

  • broadcast: true to broadcast the transaction on the network

The final parameter True states that the signed transaction will be broadcast. If this parameter is False the transaction will be signed but not broadcast, hence not executed.

The signed transaction transferring funds.

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.transfer("fromaccount","toaccount","10", "USD", "$10 gift", True);
print(json.dumps(res,indent=4))
{
  "ref_block_num": 18,
  "ref_block_prefix": 2320098938,
  "expiration": "2015-10-13T13:56:15",
  "operations": [[
      0,{
        "fee": {
          "amount": 2089843,
          "asset_id": "1.3.0"
        },
        "from": "1.2.17",
        "to": "1.2.7",
        "amount": {
          "amount": 10000000,
          "asset_id": "1.3.0"
        },
        "memo": {
          "from": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
          "to": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
          "nonce": "16430576185191232340",
          "message": "74d0e455e2e5587b7dc85380102c3291"
        },
        "extensions": []
      }
    ]
  ],
  "extensions": [],
  "signatures": [
    "1f147aed197a2925038e4821da54bd7818472ebe25257ac9a7ea66429494e7242d0dc13c55c6840614e6da6a5bf65ae609a436d13a3174fd12f073550f51c8e565"
  ]
}

transfer2

This method works just like transfer, except it always broadcasts and returns the transaction ID (hash) along with the signed transaction.

pair<transaction_id_type, signed_transaction> graphene::wallet::wallet_api::transfer2(
    string from, 
    string to, 
    string amount, 
    string asset_symbol, 
    string memo)
  • from: the name or id of the account sending the funds

  • to: the name or id of the account receiving the funds

  • amount: the amount to send

  • asset_symbol: the symbol or id of the asset to send

  • memo: a memo to attach to the transaction. The memo will be encrypted in the transaction and readable for the receiver. There is no length limit other than the limit imposed by maximum transaction size, but transaction increase with transaction size

The transaction ID (hash) along with the signed transaction transferring funds

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.transfer2("fromaccount","toaccount","10", "USD", "$10 gift");
print(json.dumps(res,indent=4))
 [b546a75a891b5c51de6d1aafd40d10e91a717bb3,{
   "ref_block_num": 18,
   "ref_block_prefix": 2320098938,
   "expiration": "2015-10-13T13:56:15",
   "operations": [[
       0,{
         "fee": {
           "amount": 2089843,
           "asset_id": "1.3.0"
         },
         "from": "1.2.17",
         "to": "1.2.7",
         "amount": {
           "amount": 10000000,
           "asset_id": "1.3.0"
         },
         "memo": {
           "from": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
           "to": "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
           "nonce": "16430576185191232340",
           "message": "74d0e455e2e5587b7dc85380102c3291"
         },
         "extensions": []
       }
     ]
   ],
   "extensions": [],
   "signatures": [
     "1f147aed197a2925038e4821da54bd7818472ebe25257ac9a7ea66429494e7242d0dc13c55c6840614e6da6a5bf65ae609a436d13a3174fd12f073550f51c8e565"
   ]
 }
]

get_account_history

Returns the most recent operations on the named account.

This returns a list of operation history objects, which describe activity on the account.

vector<operation_detail> graphene::wallet::wallet_api::get_account_history(
    string name, 
    int limit)const
  • name: the name or id of the account

  • limit: the number of entries to return (starting from the most recent)

A list of operation_history_objects.

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.get_account_history("dan", 1)
print(json.dumps(res,indent=4))
[
     {
         "description": "fill_order_operation dan fee: 0 CORE",
         "op": {
             "block_num": 28672,
             "op": [
                 4,
                 {
                     "pays": {
                         "asset_id": "1.3.536",
                         "amount": 20000
                     },
                     "fee": {
                         "asset_id": "1.3.0",
                         "amount": 0
                     },
                     "order_id": "1.7.1459",
                     "account_id": "1.2.21532",
                     "receives": {
                         "asset_id": "1.3.0",
                         "amount": 50000000
                     }
                 }
             ],
             "id": "1.11.213277",
             "trx_in_block": 0,
             "virtual_op": 47888,
             "op_in_trx": 0,
             "result": [
                 0,
                 {}
             ]
         },
         "memo": ""
     }
 ]

get_object

Returns the blockchain object corresponding to the given id.

variant graphene::wallet::wallet_api::get_object(
    object_id_type id)const
  • id: the id of the object to return

The requested object.

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.get_object("1.11.213277")
print(json.dumps(res,indent=4))
{
    "trx_in_block": 0,
    "id": "1.11.213277",
    "block_num": 28672,
    "op": [
        4,
        {
            "fee": {
                "asset_id": "1.3.0",
                "amount": 0
            },
            "receives": {
                "asset_id": "1.3.0",
                "amount": 50000000
            },
            "pays": {
                "asset_id": "1.3.536",
                "amount": 20000
            },
            "account_id": "1.2.21532",
            "order_id": "1.7.1459"
        }
    ],
    "result": [
        0,
        {}
    ],
    "op_in_trx": 0,
    "virtual_op": 47888
}

get_asset

Returns information about the given asset.

extended_asset_object graphene::wallet::wallet_api::get_asset(
    string asset_name_or_id)const
  • asset_name_or_id: the symbol or id of the asset in question

The information about the asset stored in the block chain.

import json
from grapheneapi import GrapheneAPI
client = GrapheneAPI("localhost", 8092, "", "")
res = client.get_asset("USD")
print(json.dumps(res,indent=4))
{
    "symbol": "USD",
    "issuer": "1.2.1",
    "options": {
        "description": "1 United States dollar",
        "whitelist_authorities": [],
        "flags": 0,
        "extensions": [],
        "core_exchange_rate": {
            "quote": {
                "asset_id": "1.3.536",
                "amount": 11
            },
            "base": {
                "asset_id": "1.3.0",
                "amount": 22428
            }
        },
        "whitelist_markets": [],
        "max_supply": "1000000000000000",
        "blacklist_markets": [],
        "issuer_permissions": 79,
        "market_fee_percent": 0,
        "max_market_fee": "1000000000000000",
        "blacklist_authorities": []
    },
    "dynamic_asset_data_id": "2.3.536",
    "bitasset_data_id": "2.4.32",
    "id": "1.3.536",
    "precision": 4
}
PreviousPeerplays Core APINextAccount History API

Last updated 1 year ago

This generic function can be used to retrieve any object from the blockchain that is assigned an ID. Certain types of objects have specialized convenience functions to return their objects e.g., assets have , accounts have , but this function will work for any object.

get_asset()
get_account()