Giter Site home page Giter Site logo

citycoins / protocol-api Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 530 KB

An API to interact with Stacks and CityCoin on-chain data.

Home Page: https://protocol.citycoins.co/api

License: MIT License

TypeScript 92.89% HTML 4.33% CSS 2.78%
api citycoins cloudflare stacks

protocol-api's People

Contributors

whoabuddy avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

protocol-api's Issues

`get-balance-stx` for ccd002-treasury only returns unlocked balance

The current endpoint for get-balance-stx returns the unlocked balance, e.g.

https://protocol.citycoins.co/api/ccd002-treasury/get-balance-stx?contractName=ccd002-treasury-mia-mining-v2

Returns:

155844000

Which matches the unlocked balance and doesn't indicate anything about the 10.2M STX locked.

image

This comes from stx-get-balance in the treasury contract, so we may need to switch to calling the Hiro API.

https://api.mainnet.hiro.so/extended/v1/address/SP8A9HZ3PKST0S42VM9523Z9NV42SZ026V4K39WH.ccd002-treasury-mia-mining-v2/stx

Returns:

{
  "balance": "10216532085394",
  "total_sent": "0",
  "total_received": "10216532085394",
  "total_fees_sent": "0",
  "total_miner_rewards_received": "0",
  "lock_tx_id": "0x117c1a1ccb8242cdaf52012623a52fadb0f0e78cb34e0ad4f7046717dc92f8be",
  "locked": "10216376241394",
  "lock_height": 107391,
  "burnchain_lock_height": 791949,
  "burnchain_unlock_height": 794150
}

Gate default results by block height / cycle

Once we know the block height that ccip013-activation executes, it can be used here to prevent returning data that should be queried in the legacy contracts.

This came from a point @Tim-Butterfield pointed out in Discord:

For example, this call returns data that isn't valid .
https://protocol.citycoins.co/api/ccd006-citycoin-mining/get-mining-stats?cityId=1&height=96250
According to MIAmining explorer, that block was won and already claimed, but the API says there were no miners.

data disparity

There seems to be some disparity in how much data is returned and of what type. Here are a few examples:

https://protocol.citycoins.co/api/stacks/get-block-height - returns full JSON including redundant path and params

https://protocol.citycoins.co/api/ccd004-city-registry/get-city-id?cityName=mia - returns just the number in quotes "1"

https://protocol.citycoins.co/api/ccd005-city-data/is-city-activated?cityId=1 - returns the boolean false

I'm not asking about the specific values, but of the types of data returned and the differences between simple data and full JSON. I would have expected the get-block-height function to be called regularly and have simple data also, but it didn't.

Is this an issue or expected behavior?

Accept tip parameter to return past data

The Stacks Blockchain API supports a tip parameter for read-only contract calls, which can bring up the data at a certain point in time based on the index_block_hash of the Stacks block height.

Ideally we could support specifying the tip as a hash, a block height, or a cycle number.

  • tip (hash) could be passed directly
  • block height would require a query to get index_tip_hash
  • cycle number would require a query to get first-block-in-cycle, then index_tip_hash

The value would be passed as part of the ReadOnlyFunctionOptions, and is accepted by micro-stacks.

image

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.