Binance API transaction history - api

I am trying to display a users transaction history in binance, including fund deposits and withdrawals as well as buying and selling of different crypto's. Does anyone know which binance API endpoints I would use to do this? It seems quite complicated in comparison to other trading platforms.
Thanks
This is the link to the docs: https://binance-docs.github.io/apidocs/spot/en/#withdraw-history-supporting-network-user_data
I can see the Wallet endpoints "Withdraw" and "Deposit", but this won't cover crypto trading will it?, The account trade list call would be ideal, but it requires a symbol input which I'm not sure how I would obtain dynamically.
I would also like this endpoint to provide me with the data so I can get the avg buy price for a crypto

Currently this is not supported. See: https://dev.binance.vision/t/fetch-all-account-orders/279/3

This is the route you're looking for to get the user trade history. The big downside is that you have to specify the exchange symbol, you cannot get the history of the account with just one request:
https://binance-docs.github.io/apidocs/spot/en/#account-trade-list-user_data

Get your account information first. You can then extract non-zero balances from here to get symbols for transactions. You can then loop through each currency pair and get its transaction history. This seems to be the most optimistic way we can get right now
You can also try to use caching. For example, you can remember balance for a particular coin, and if it has not changed by the next launch, then it is likely (but not 100%) that no transactions were made with it
You can also connect to WebSocket, but this is still a terrible crutch and requires a DOS attack to get the necessary data
Please note that here the balances for Savings wallet have LD prefix added to their ticker. For example, BTC in the Savings wallet is labeled as LDBTC

Related

Funding Chainlink VRF Dynamically

I am trying to wrap my head around how Chainlink VRF integrates into Solidity contracts, such as in this randomly generated NFT tutorial: https://blog.chain.link/random-numbers-nft-erc721/
My question is around the actual funding of the oracle. In the Chainlink VRF documents, this warning is displayed: "Requesting randomness will fail unless your deployed contract has enough LINK to pay for it. Learn how to Acquire testnet LINK and Fund your contract." An example is given of how to fund the VRF contract with metamask and Remix.
However, I'm not really sure how this would work on a large scale. If you have an NFT "factory" that becomes very popular with potentially many requests per day/hour/minute, are you just expected to front run the funding of this VRF contract to avoid the aforementioned warning (seems like the costs would be non-trivial / hard to predict)?
Alternatively, if you wanted your NFT consumer to fund it, would you have to build in some logic that converts Ether to Link and then sends it to the oracle contract? (or make them go buy Link token?)
I could be looking at this the wrong way, but the scalability just doesn't seem well described in the documentation and only looked at from a testing / test network standpoint. Thank you.
You can:
Move the costs directly to the caller
Require LINK payment, or some other form of payment that will cover the costs of oracle request
Request the oracle data in a smaller frequency (if your use case allows it)
Are you receiving some price info from an oracle? Is it sufficient to update the price info once a day instead of once an hour?
Change your contract logic to not require (that much) oracle data
Does your factory really need off-chain random number generation? Wouldn't be sufficient to generate "random" number from the blockhash, difficulty, etc.?
My suggestion is, maybe a little awkward, but for the sake of decentralization, could work.
You charge your Contract1 with a sufficient link to get started
Charge every minter the equivalent link transaction cost in eth (+ the % that covers the costs of the trade to link and transfer between contracts)
As they mint, it is incorporated into the price and the eth is sent to Contract2.
In Contract2 simply exists a public callable function to initiate a swap for the link via routerV2 or a similar contract.
By placing a call to this function and contract, you can then just let any minter activate the swap contract function
The eth in Contract2 will be sent back to Contract1 as a link.
You could have a counter go and then call Contract2 every time the link fund is low and refill it automatically.
If you build it into the mint, then the inter will cover the fees.

How to get historic Bitcoin Price Index using coinbase or any other open source API

I would like to get a history of the bitcoin price.
For example I would like to be able to provide a start_date and end_date for a search/filter.
Are there any open source and trusted api with almost accurate prices for this?
I have noticed that coinbase only returns the spot/current price and I cannot pass more params to filter
curl https://api.coinbase.com/v2/prices/spot?currency=USD
I have also used coindesk but the prices are not accurate.
https://api.coindesk.com/v1/bpi/historical/close.json?start=2019-08-10&end=2020-08-11&currency=zar
bitcom.com does not provide historical prices, it is wallet and kinda banking services.
API for pro.bitcom.com, (crypto exchange) provides to historical prices.
https://docs.pro.coinbase.com/#get-historic-rates
I would recommend you to use the CoinMarketCap API if what you want are historical prices.
There are also libraries like ccxt where you can probably find this information as well.
However you have keep in mind that due to the number of exchanges these prices are approximations, and there is not sucha thing as a "unique" price for bitcoin.

Why do bitcoin uses UTXO model? What are the advantages UTXO mechanism provides out of the box?

I am just curious to know why Bitcoin developers choose a complicated approach like UTXO, rather than using the transaction models used by Ethereum Blockchain.
Basically, Bitcoin nodes maintain a set of all active UTXOs which have not been spent yet and any transaction that comes in is validated using this set. The nodes also update the UTXO set after every transaction.
This model is very analogous to how you'd implement a "wallet" which held currency notes and coins albeit with perfect traceability of each note in your wallet as to where you received it from! It is not complicated once you understand this basic analogy.
Consider the case where you have only a 20$ bill in your wallet. Let's say you buy a product worth 6$ with this 20$ bill. In this case, you will get BACK 14 $ in "change" and these notes are akin to the "unspent transaction outputs". These notes (UTXOs) can then be spent in any later transaction.
The advantage that UTXOs have is that each UTXO can be traced back right upto the point where the actual bitcoin was created (miner reward for example) and even upto the genesis block potentially.
This is akin to your being able to trace back the 20$ bill from where/whom you received it, and in succession being able to trace back how that person received this 20$ bill and so on and so forth until you traced it back to the Federal Reserve Bank mint where it was printed!
You can imagine how this would dramatically increase the security and trust in the system because you could validate each and every facet of a transaction.
However, this model was considered as not efficient enough for the Ethereum protocol which also has smart contract transactions which might execute frequently. Due to this, Ethereum went for a "Account state" based model which makes it far more efficient to calculate balances before and after transactions.
Here are some helpful links that might answer your question:
Considered as skewed towards a pro-ethereum viewpoint - https://ethereum.stackexchange.com/questions/326/what-are-the-pros-and-cons-of-ethereum-balances-vs-utxos
Also a Medium article which goes into more detailed comparison on the UTXO and Ethereum Account State model https://medium.com/#sunflora98/utxo-vs-account-balance-model-5e6470f4e0cf

Is there a Plaid data field comparable to the Simple Description from Yodlee?

I'm currently evaluating using Plaid or Yodlee for transaction aggregation (I'm using the Dev environments for both right now). I really prefer almost everything about Plaid, but I'm having trouble with transaction name/description. Yodlee has a data field called the "simple description":
From their docs: "The transaction description that appears at the FI site may not be self-explanatory, i.e., the source, purpose of the transaction may not be evident. Yodlee attempts to simplify and make the transaction meaningful to the consumer, and this simplified transaction description is provided in the simple description field."
I'm displaying the transaction name to my end-users and I'm looking for something more user friendly than the transaction name field which often returns strings like "Withdrawal Check Card MOE'S BROADWAY BAGE BOULDER CO Date 01/06/19 0 9006020339 0 5812 Card [XXXX]".
I'm sure I'm not the first plaid customer to have this need. How do Plaid reliant apps solve this problem?
Plaid doesn't offer a simple description field as far as I know, but they do clean up transaction names.
I've found that when a new pending transaction comes in, the name is messy like you mention (e.g. UBER *TRIP 5VVB2). But once the transaction is confirmed, Plaid normalizes it for common merchants (e.g. Uber). I don't know why Plaid doesn't offer this normalization for pending transactions, but I have brought it up with them before. Perhaps this is something that could change in the future?
A solution, albeit complicated, is to build a custom model that normalizes transaction names. That's what we are doing at Pluto Money to supplement Plaid's transaction data.
I received a direct response by email from Plaid Support:
Thanks for reaching out to us here on Plaid Support, I'm sorry about
our delay.
Our name​ field for each transaction represents our best effort to
balance detailed transaction information while providing a clean and
consistent API response. This behavior does vary across banks, both
due to bank behavior and our own integration quality. Generally at
larger banks our integrations do a better job at returning clean
transaction name​s with appropriate transaction detail but for some of
our smaller banks transaction name​s may be more "raw".
If you never want additional detail beyond the merchant/transaction
name in your app I would encourage you to implement some filtering on
Plaid's name​ field to make sure that no date- or account number-like
character strings pass through into your user facing stream.

Validating Bitcoin Payments Programmatically

Is it possible to anonymously programmatically verify that a transaction has reached n number of validations without running a full node? If so, what is the best means to do this?
Basically I want it to build a payment system where after the transfer is initially detected, the customer sees a message thanking them and telling them that their purchase will be processed within 24 hrs and that they'll receive an email once confirmation is complete. Then throughout the day maybe run a cron job that checks that each transaction reaches the desired number of validations and if so divide the money between two wallets and mark the product to be sent. I also don't want it to be with a service like Coinbase or Bitpay where they have control of your coins.
So far I've been experimenting with Blocktrail and mycelium gear. Both have some elements I like but still not everything that I need. With mycelium you can set the number of verifications but for instance if I want to set it for 6 verifications the customer would have to sit there possibly an hour before they see the next screen. Blocktrail allows me to query that a transaction is validated but it only has the ability to check that 1 validation was completed as far as I can tell. Can anyone suggest an API or widget that can accomplish these things? Preferably PHP or if not JQuery.
Blockchain.info has a simple Query API for querying how much bitcoin an address has received. You can add a confirmations=n parameter that will only include bitcoin that has been confirmed 'n' times. It returns a simple value in satoshis.
For example to check how much bitcoin was received with at least 2 confirmations at a specific address you could have your code query the API like this:
https://blockchain.info/q/getreceivedbyaddress/1PFtyX9nQvjP8U2N3iUk2oNorzPfpjX9sK?confirmations=2