You are viewing a single comment's thread from:

RE: Looking for the Crypto Shots account?

in #cryptoshots11 months ago (edited)

DAPPRADAR TRACKING

"Could you share different types of dapp transaction examples explaining..."

1. who the sender is

HIVE

  • PVE: @cryptoshotsdoom → it sends to players only our Hive-Engine token DOOM
  • PVP: @cryptoshots.tips and @karina.gpt → they send to players HIVE transfers, Hive-Engine token DOOM and sponsored HE tokens (vary)
  • TRADING for our Hive-Engine token DOOM:
    Direct match between buyers and sellers (Hive-Engine does not support custom smart contracts out-of-the-box).
    Plus swaps in the SWAP.HIVE/DOOM liquidity pool: https://tribaldex.com/dieselpools/pools
    Secondary Hive-Engine tokens coming: MARS, FOOD, GAS.

WAX

  • PVE: crypto4shots: it sends to players only our Wax token BOOM
  • PVP: crypto1shots (added this address in DappRadar and awaiting approval) → it send to players WAX transfers, WAX token BOOM and Sponsored Wax tokens (vary)
  • TRADING:
    Match buyer/sellers through our smart contract leveraged on the Alcor DEX: @csboomcsboom
    Plus swaps in the WAX/BOOM liquidity pool: https://wax.alcor.exchange/positions
    Secondary Wax tokens (live): MARS, FOOD, GAS.

2. who the receiver is

HIVE

  • PVE: any Hive player
  • PVP: any Hive player
  • TRADING: any Hive user

WAX

  • PVE: any Wax player
  • PVP: any Wax player
  • TRADING: any Wax user

3. and where the value is sent?

It’s sent from the sender to the receiver.
If that’s what you need, to know the value of the token at the time of the transfer, I quickly put together these scripts and they work as expected to fetch the current $ value of our tokens:

HIVE:

var getHiveEngineTokenPrice = async ({ tokenName }) => {
  const tokenInfoUrl = `https://api.hive-engine.com/rpc/contracts`;
  const tokenInfoBody = {
    "jsonrpc":"2.0",
    "method":"find",
    "params": {
        "contract":"market",
        "table":"metrics",
        "query":{ "symbol": tokenName },
        "limit": 1,
        "offset": 0,
        "indexes":[]
    },
    "id":1
  };
  const tokenInfoResponse = await fetch(tokenInfoUrl, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(tokenInfoBody),
  });
  const tokenInfoData = await tokenInfoResponse.json();
  const lastPrice = tokenInfoData.result[0].lastPrice;
  console.log(`$${tokenName} current price on Hive-Engine: ${lastPrice} HIVE`);
  const hivePriceUrl = `https://api.coingecko.com/api/v3/simple/price?ids=hive&vs_currencies=usd`;
  fetch(hivePriceUrl)
    .then(response => response.json())
    .then(data => {
      const priceUSD = data.hive.usd;
      console.log(`HIVE current price is $${priceUSD}`);
      const tokenPriceUSD = lastPrice * priceUSD;
      console.log(`The current price of $${tokenName} in USD is $${tokenPriceUSD.toFixed(4)}.`);
    });
};

var tokenName = 'DOOM';
getHiveEngineTokenPrice({ tokenName });

 
WAX:

var getFungibleTokenPrice = async ({ tokenPair }) => {
const { tokenName, cryptoName, marketNumber } = tokenPair;
const cryptoNameLc = cryptoName.toLowerCase();
  const data = await fetch(`https://wax.alcor.exchange/api/markets/${marketNumber}/deals`).then(res => res.json());
  const lastTransactionPrice = data[0].unit_price;
  console.log(`$${tokenName} current price on the open market: ${lastTransactionPrice} ${cryptoName}`);
  fetch(`https://api.coingecko.com/api/v3/simple/price?ids=${cryptoNameLc}&vs_currencies=usd`)
    .then(response => response.json())
    .then(data => {
    const priceUSD = data[cryptoNameLc].usd;
    console.log(`$${cryptoName} current price is $ ${priceUSD}`);
    const tokenPriceUSD = lastTransactionPrice * priceUSD;
    console.log(`The current price of $${tokenName} is $ ${tokenPriceUSD.toFixed(4)}.`);
  });
};

var tokenPair = {
  tokenName: 'BOOM',
  contract: 'csboomcsboom',
  cryptoName: 'WAX',
  marketNumber: 368,
};
getFungibleTokenPrice({ tokenPair });

OTHER CONSIDERATIONS

From a conversation with crim:

  • In PVP:
    DappRadar seems to track correctly only Hive transfers, so only PVP token rewards received by winners. That means that currently it doesn't track as active users players that don't win.
    Also, I believe that it’s not tracking Hive-Engine token transfers (our token, sponsored tokens, our NFT transfers).

We plan on broadcasting a custom_json operation on chain with the match summary at the end of every 5-min PVP match. It will contain the match participants (max 8 per room), match result and kill log.
ie.

{
  "matchId": "MTcwNzUxNDc5NDYzNC1jcnlwdG9zaG90cy5uZnQtcHZl",
  "startTime": 1707514794634,
  "endTime": 1707514865805,
  "mode": "PVP",
  "map": 0,
  "players": ["pvp-player1", "pvp-player2"],
  "winner": "team-alpha",
  "killLog": ["0-1:10","1-0:160","0-1:240"]
}

This way Dappradar should be able to track active users by using the players array field.

  • In PVE:
    If, as we think, DappRadar currently doesn't account for HE tokens, then in PVE it's tracking nothing on the Hive side.
    And even if it were tracking HE transfers, at the moment in PVE it would track only transfers when players claim their rewards. And in our case it could be N matches together; they could even be grouped for different days.
    Also, it can't track active players if they leave rewards staked in-game to get some perks.

So same here, we plan on broadcasting a custom_json operation on chain after every PVE match with the player name and match result.

{
  "matchId": "MTcwNzUxNDc5NDYzNC1jcnlwdG9zaG90cy5uZnQtcHZw",
  "startTime": 1707514794634,
  "endTime": 1707514865805,
  "mode": "PVE",
  "map": 2,
  "players": ["some-pve-player"],
  "winner": "bots",
  "killLog": ["1:10","0:16","2:24", "0:32", "0:45"]
}

This way Dappradar should be able to track active users by using the players array field.


How does a custom_json operation on the Hive blockchain looks like:

block_num   82670298
expiration  2024-02-09T23:53:30
extensions  []
operations  [["custom_json", {"id": "ssc-mainnet-hive", "json": "{\"contractName\":\"tokens\",\"contractAction\":\"stake\",\"contractPayload\":{\"symbol\":\"DOOM\",\"to\":\"athunderstruck\",\"quantity\":\"6.6700\",\"memo\":\"Crypto Shots PVP Alpha reward. GG!\"}}", "required_auths": ["cryptoshots.tips"], "required_posting_auths": [] }]]
ref_block_num   29401
ref_block_prefix    2126063433
signatures  [ "1f5054e3996f04805b4a7b070c78d94cd50ee8097094f832335b7119199ca421470e6a5a6c6e63c6dc272eb6ca549761b4c176f209eb3de0a049ccbbc9e3472057" ]
transaction_id  9ee3b9672bf71e0e5d853cb44dfb275ed2fd46a8
transaction_num 80

Example of how to stream blocks of the Hive blockchain and parse custom_json operations found in blocks:

const fetch = require('node-fetch');
const { Client, Blockchain } = require('@hiveio/dhive');

const fetchHealthyHiveNode = () => fetch(
  'https://beacon.peakd.com/api/nodes',
  {
    credentials: 'omit',
    headers: { Accept: 'application/json' },
    method: 'GET',
  },
)
  .then((res) => res.json())
  .then((allNodes) => {
    const healthyNodes = allNodes.filter(({ score } = {}) => score === 100);
    return ({ hiveNode: healthyNodes[0].endpoint });
  })
  .catch((fetchErr) => ({ err: `Url fetch failed: ${fetchErr}` }));

const streamBlocks = async () => {
  const { err, hiveNode } = await fetchHealthyHiveNode();
  if (err) return;
  const client = new Client(hiveNode);
  const blockchain = new Blockchain(client);
  console.log('Streaming blocks from', hiveNode);
  blockchain.getBlockStream()
    .on('data', (block) => {
      console.log(`Received block #${block.block_id} containing ${block.transactions.length} transactions`);
      block.transactions.forEach(
        tx => tx.operations.forEach(
          op => op[0] === 'custom_json' && console.log(op[1]),
        )
      );
    })
    .on('error', console.error);
};
streamBlocks();

- (( For transparency every 15th of the month we also take a snapshot and post all game stats (json) on the Hive chain at the same permlink, but I doubt they can consume that. ))


crim:
Is there enough data right now from HE not being tracked that adding it would make a big difference?

gabe:

  • PVP: if they start tracking HE, they still wont capture users that didnt win. Minor/medium improvement.
  • PVE: helps a bit but not much. They track PVE claims but usually it's once per user per day.
    Tracking HE though will fix our $ volume that has always been wrong both on Hive and Wax.
    Same for the daily transactions count.