WETH Transaction does not appear in the web3.eth.get_transaction - python

I am trying to understand how can I see the amount of WETH transferred in a transaction. for example on OpenSea. When you go to etherscan you can see the amount. but if you use web3.eth.get_transcation(tx_hash) you will find the value to be 0 ( since its WETH and not ETH).
Any suggestions?

I'm also having trouble with this.
The Phunkbot code is on github (https://github.com/albanow/phunks-nll-twitter-bot/blob/main/bot.py), and this part from the 'input' is interesting:
bid = "0x6d728796"
sale = "0xf8529df3"
accepted_bid = "0xbad9f860"
Somehow the first 10 characters of the 'input' hex is a sign of what kind of transaction it is? Doesn't seem to be the case for the contract I'm trying to monitor but maybe this code will lead you somewhere.

Related

python-binance: Get all orders, without specifying symbol

Trying to fetch my Binance accounts order history with the python-binance module. There is an option to get all orders within one symbol (see documentation):
orders = client.get_all_orders(symbol='BNBBTC', limit=10)
Bu the problem is I can't pass more than 1coin in the symbol parameter
How can I pass a list for the symbol parameter, I want to fetch more than 1 coins order history in a single function
as I'm trying to build a portfolio for my Binance account. Or is there another method to do so?
Currently it is not possible to get all historical orders or trades without specifying the symbol in one call, even without the module python-binance.
There is an ongoing discussion on the Binance forum, requesting this feature.
As a workaround:
If you know your ordered symbols: Use the function get_all_orders() multiple times for each symbol in a loop.
If you don't know your ordered symbols: you could send a GET request for each symbol available at Binance (as mentioned in the discussion linked above). But be careful with the rateLimits.
I was asking myself the same thing. Well, a work around would be to iterate over all the tickers available in Binance looking for the ones we did traded in the past.
If you are working the free plan of the API, the best would be to setup a storage file or database and store all the result. Then you have to care about keeping with the changes from there.
Yeah, it is exactly how I am going to deal with this.
(edit) :
Sleep function will be needed to avoid more than 1200 queries per minute.
(example) :
def getAllTickers(self):
# Get all available exchange tickers
exchangeInfo = self.client.get_exchange_info()
# Extract the tickers general info
exchangeSymbols = []
for i in exchangeInfo['symbols']:
exchangeSymbols.append(i)
return exchangeSymbols
def getMyTrades(self, strSymbol):
return self.client.get_my_trades(symbol=strSymbol)
def getMyTradedTickers(self):
tickers = self.getAllTickers()
# Extract every ticker where trade happened
traded = []
for i in tickers:
tickerTransactions = self.getMyTrades(i["symbol"])
if tickerTransactions :
traded.append(tickerTransactions)
print(i["symbol"], " transactions available")
else :
print(i["symbol"], " has no transactions")
self.time.sleep(0.1)
return traded
**Srry for the code quality. Python is not my main coding language and im getting use to it.

Replace multiple values in string using replace, sub string and find in Python

So im pulling issues from our jira project and I need to replace url's with new formatted url's in the description.
old description contains the old sharepoint server URL's so I need to change them to our new online Sharepoint url.
I decided to use Python to make use of the atlassian plugin.
here is a version of how the description looks like in the jira issue currently:
Good day
we need a new validation on the External Reference when doing work pads or amending manually when we do refund, it seems that the user that updates this is using Tab or Enter and therefore the payment files fails ,
we need users to be validated while updating refund reference same way as we limited claims payments for updating invoice numbers
thank you
regards
*BRS & FRS:*
[BRS_FRS_PS_ACC_Payments_v20.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
*Sign Offs:*
[BRS_FRS_PS_ACC_Payments_v20.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FPayments%2FV20%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FWorkpads%20%26%20incoming%20payments%2FV5%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B9A71C976%2D85D3%2D4D34%2D828B%2DE5B1B428EA5E%7D]
*Technical Documentation:*
N/A
*Unit Testing:*
[TU_dd-1821|http://portal.mycompany.local/mycompany/someproject/SitePages/Home.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2Fsomeproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FUnit%20Testing&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B5AF02A9E%2D451A%2D443D%2DB8CA%2DAF7C7ED6F00C%7D]
this is how i pulled in the issue from Jira( my plan is to scan through all issues and update.
from jira import JIRA
import re
jira = JIRA(server=('https://mycompanydev.atlassian.net'),basic_auth=('user', 'password'))
issue = jira.issue("S1-3000")
print("Ticket nr: ", issue)
olddescription = issue.fields.description
newdescription = olddescription
So i managed to change the first part of the url with this line:
newdescription = newdescription.replace("http://portal.mycompany.local/mycompany/someproject/_layouts/15/start.aspx#/someproject/Forms/AllItems.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2F", "https://somecompany.sharepoint.com/sites/CCPortal/")
and this line:
newdescription = newdescription.replace("http://portal.mycompany.local/mycompany/someproject/SitePages/Home.aspx?RootFolder=%2Fmycompany%2Fsomeproject%2F", "https://mycompany.sharepoint.com/sites/CCPortal/")
this code completes successfully and changes the URL as intended.
Now i need to remove the end of the url from the string "View=" and the string "FolderCTID="
my line of code to do this:
newdescription = newdescription.replace(newdescription[newdescription.find("View=")-1:newdescription.find("]")],"")
and:
newdescription = newdescription.replace(newdescription[newdescription.find("FolderCTID="):newdescription.find("]")], "")
for some reason it only does the first 2 URLs:
result looks like this:
Good day
we need a new validation on the External Reference when doing work pads or amending manually when we do refund, it seems that the user that updates this is using Tab or Enter and therefore the payment files fails ,
we need users to be validated while updating refund reference same way as we limited claims payments for updating invoice numbers
thank you
regards
*BRS & FRS:*
[BRS_FRS_PS_ACC_Payments_v20.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS]
*Sign Offs:*
[BRS_FRS_PS_ACC_Payments_v20.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FPayments%2FV20%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6]
[BRS_FRS_PS_ACC_Workpads_Manual_Write_Off_and_Incomming_Paument_v5.0|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FBRS%20%26%20FRS%2FSign%2Doffs%2FWorkpads%20%26%20incoming%20payments%2FV5%2E0&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6]
*Technical Documentation:*
N/A
*Unit Testing:*
[TU_MV-1821|https://mycompany.sharepoint.com/sites/mycompany/someproject%2F06%20Solution%20Documentation%2F03%20Accounting%2C%20Etc%2F07%20TIA%2FUnit%20Testing&FolderCTID=0x0120005C60D5FB65C2C84191CB5ACDFD820AA6&View=%7B5AF02A9E%2D451A%2D443D%2DB8CA%2DAF7C7ED6F00C%7D]
as you can see the code removed the first 2 "View=" strings with the trailing string to the end.
I cant figure out where I went wrong I also tried putting this in a while loop and just repeating the code 5 times for a test.
str.find returns the lowest index where the substring is found. So if newdescription has more than one "]", presumably because it contains more than one link, that means the returned index will only be correct for the first link.
str.find also accepts an optional start/end index to limit the search, so you can use the index of "View=" as an offset for the search for "]":
offset = newdescription.find("View=")
replace_me = newdescription[offset:newdescription.find("]", offset)]
newdescription = newdescription.replace(replace_me, "")

Basics of connecting python to the web and validating user input

I'm relatively new, and I'm just at a loss as to where to start. I don't expect detailed step-by-step responses (though, of course, those are more than welcome), but any nudges in the right direction would be greatly appreciated.
I want to use the Gutenberg python library to select a text based on a user's input.
Right now I have the code:
from gutenberg.acquire import load_etext
from gutenberg.cleanup import strip_headers
text = strip_headers(load_etext(11)).strip()
where the number represents the text (in this case 11 = Alice in Wonderland).
Then I have a bunch of code about what to do with the text, but I don't think that's relevant here. (If it is let me know and I can add it).
Basically, instead of just selecting a text, I want to let the user do that. I want to ask the user for their choice of author, and if Project Gutenberg (PG) has pieces by that author, have them then select from the list of book titles (if PG doesn't have anything by that author, return some response along the lines of "sorry, don't have anything by $author_name, pick someone else." And then once the user has decided on a book, have the number corresponding to that book be entered into the code.
I just have no idea where to start in this process. I know how to handle user input, but I don't know how to take that input and search for something online using it.
Ideally, I'd be able to handle things like spelling mistakes too, but that may be down the line.
I really appreciate any help anyone has the time to give. Thanks!
The gutenberg module includes facilities for searching for a text by metadata, such as author. The example from the docs is:
from gutenberg.query import get_etexts
from gutenberg.query import get_metadata
print(get_metadata('title', 2701)) # prints frozenset([u'Moby Dick; Or, The Whale'])
print(get_metadata('author', 2701)) # prints frozenset([u'Melville, Hermann'])
print(get_etexts('title', 'Moby Dick; Or, The Whale')) # prints frozenset([2701, ...])
print(get_etexts('author', 'Melville, Hermann')) # prints frozenset([2701, ...])
It sounds as if you already know how to read a value from the user into a variable, and replacing the literal author in the above would be as simple as doing something like:
author_name = my_get_input_from_user_function()
texts = get_etexts('author', author_name)
Note the following note from the same section:
Before you use one of the gutenberg.query functions you must populate the local metadata cache. This one-off process will take quite a while to complete (18 hours on my machine) but once it is done, any subsequent calls to get_etexts or get_metadata will be very fast. If you fail to populate the cache, the calls will raise an exception.
With that in mind, I haven't tried the code I've presented in this answer because I'm still waiting for my local cache to populate.

pyxero get LineItems on banktransactions

I'm running pyxero and trying to get the reference and description from a bank transaction but am having trouble getting it.
I can run:
trans = xero.banktransactions.filter(BankAccount_Name="chosen_account")
Which gives me the transcations and details, however the reference and description are not present.
It also shows the LineItems are empty:
'LineItems': []
I also get the same if I try:
transaction = xero.banktransactions.filter(BankTransactionID=BankTransactionID)
Is there a way to get this information?
Many thanks
Need to use get instead of filter to get the LineItems:
transaction = xero.banktransactions.get(BankTransactionID)
To get all the lineitem detail you either need to :
retrieve a specific item by BankTransactionID (as #blountdj implies in their answer)
OR
use Xero API's built-in paging in the request by passing 'page=xxx' as an optional parameter (which you might need to loop through multiple pages/requests if >100 transactions - which is likely).
Refer Xero API reference re Bank Transaction paging here

LinkedIn REST API does not return end-date with python

I'm working on Linkedin REST API. I cannot get postions' end-date.
connectionsdic = application.get_connections(selectors=['id',
'positions','specialties','first-name','last-name',
'headline','public-profile-url','site-standard-profile-request'],
params=`{'start':130, 'count':100})
I can get anything else.
Edit: I changed my code to be most straight, but still same result...
Try just specifying positions without the :['end-date'] part, in the same you specify educations.
Also note that end date will not be returned if the position is current.

Categories