Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:10
    kclowes commented #1894
  • 16:10
    kclowes closed #1894
  • Mar 06 22:14
    JoshuaMulliken opened #1894
  • Mar 05 15:55
    tmckenzie51 synchronize #1886
  • Mar 05 15:47
    tmckenzie51 synchronize #1886
  • Mar 05 15:38
    kclowes commented #1730
  • Mar 05 14:57
    tmckenzie51 synchronize #1886
  • Mar 05 06:11
    takipsizad commented #1730
  • Mar 04 21:18
    kclowes review_requested #1893
  • Mar 04 21:18
    kclowes review_requested #1893
  • Mar 04 21:17
    kclowes edited #1893
  • Mar 04 20:21
    marcgarreau edited #1887
  • Mar 04 20:20
    marcgarreau edited #1887
  • Mar 04 20:07
    kclowes edited #1893
  • Mar 04 20:07
    kclowes synchronize #1893
  • Mar 04 20:05
    kclowes edited #1893
  • Mar 04 20:02
    kclowes synchronize #1893
  • Mar 04 19:58
    kclowes synchronize #1893
  • Mar 04 19:57
    kclowes opened #1893
  • Mar 04 16:42
    marcgarreau commented #661
Jason Young
@Morgon
For now I'm just casting it toHex() and slicing [26:] (0x plus the leading 24 characters). Hacky, but it's something.
Jason Young
@Morgon
(though [-40:] is probably safer, just to be pedantic)
Lanski
@Pol-Lanski
Hey there! So... I'm probably being super dumb - but I started using web3.py in a jupyter notebook and it connects to the node just fine... but I can't seem to use any .eth methods as it throws a: AttributeError: 'Eth' object has no attribute 'get_block'
Elnaril
@Elnaril
Hello Everyone ! I'm trying to swap tokens with the 0x API, using web3.py but I have an error and can't figure out if I miss something or if web3.py does not support the protocol's requirements. I came accross the fork 0x-web3.py, but got the same error.
I am following these web3.js instructions : https://0x.org/docs/guides/swap-tokens-with-0x-api#buy-1-dai-with-eth
In [5]: import requests

In [6]: parameters = {'buyToken': 'DAI','sellToken': 'ETH','buyAmount': '1000000000000000000',}

In [7]: r = requests.get('https://kovan.api.0x.org/swap/v1/quote', params = parameters)
So far so good, I receive the 0x quote which is supposed to be formatted as a transaction we just have to sign and send.
Elnaril
@Elnaril
I add a few things to this transaction, like the nonce, chainId, From, sellTokenAddress. I reformat the "to" address to be a valid checksum one.
But when I sign it in order to use send_raw_transaction() (I use Infura, not a local node) I have a TypeError because this transaction contains unusual fields
This message was deleted
This message was deleted
TypeError: Transaction must not include unrecognized fields: {'estimatedGas', 'sellTokenAddress', 'buyAmount', 'price', 'guaranteedPrice', 'allowanceTarget', 'sources', 'sellAmount', 'orders', 'buyTokenAddress', 'minimumProtocolFee', 'protocolFee'}
Elnaril
@Elnaril
It's the same error with 0x-web3.py
I could not find a similar issue on GitHub, so I wonder if I miss something
Can someone please advise ? :-)
dynamictrader
@dynamictrader
signed_txn = w3.eth.account.sign_transaction(dict(
nonce=w3.eth.get_transaction_count(public_address_of_senders_account),
gasPrice=w3.eth.gas_price,
gas=100000,
to='0xd3CdA913deB6f67967B99D67aCDFa1712C293601',
value=12345,
data=b'',
),
private_key_for_senders_account,
)
w3.eth.send_raw_transaction(signed_txn.rawTransaction)
HexBytes('0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331')
Looks like you may have sent too many/invalid parameters
Elnaril
@Elnaril
@dynamictrader Thank you very much for your answer :-)
The thing is that those invalid parameters, in my understanding, are required to use the 0x protocol.
Elnaril
@Elnaril
And since I was not able to figure out what I could possibly miss or misunderstand, I was wondering if web3.py allows 0x swaps. I'll give another try today.
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver, Jason Carver> @Pol-Lanski what version of web3.py do you have? get_block is only in v5.15.0+ https://web3py.readthedocs.io/en/stable/releases.html#v5-15-0-2021-01-15
<carver, Jason Carver> @Elnaril those extra parameters don't exist in the base transaction, they get encoded into the data field of the transaction. So you would need to create a contract object, call the contract method with the needed parameters, then use buildTransaction() to get the complete unsigned transaction. For example: https://web3py.readthedocs.io/en/stable/web3.eth.account.html#sign-a-contract-transaction
Elnaril
@Elnaril
@carver Thank you so much for your help ! :-) I will definitively dig into that !
eyooooo
@eyooooo
hello! im new to geth and evm, appreciate anyones help on this. i am iterating over blocks, then txid in each block, looking for certain strings. when i find a match i want to return the contract address being created, as my string will appear in a creation tx. but when i do get_transaction on a create tx i dont get the contract address
any advice?
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver, Jason Carver> The receipt contains newly-created contract address if created by the externally owned account. I'm not sure there's a clean way to iterate over all newly created contracts in a given transaction (if a subcall creates a contract, for example)
eyooooo
@eyooooo
what is eth-gitter-bridge?
are you responding to me from another discord or something?
if you are replying to me, which is totally unclear, yes i was able to get this info via gettransactionreceipt()
and if ur replying to me, thanks
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver, Jason Carver> Yup, that was for you eyooooo - glad you got it working
This room is bridged to the internal Ethereum Foundation Discord
There is also a python-focused Ethereum community Discord, also
<carver, Jason Carver> https://discord.gg/9XazthJx2J
garyzava
@garyzava

Hello, I am trying to call a transaction with a uint256 paramater, but no luck at all. Any advise?

Error message:
Could not identify the intended function with name purchase, positional argument(s) of type (<class 'int'>, <class 'str'>) and keyword argument(s) of type {}.
Function invocation failed due to improper number of arguments.

Marc Garreau
@marcgarreau
@garyzava how are you calling the function? a python int is fine to pass in as uint256, but the error msg suggests you’re also passing in a string. is that intentional?
Peteris Erins
@Pet3ris
What's the best way to send a transaction from an arbitrary account using web3.py/eth_tester? Is there a canonical "unlock account" endpoint perhaps? I only see unlock account support for geth and parity in the new API.
Mikko Ohtamaa
@miohtama
@Pet3ris I usually just import a private key, sign locally and then broadccast
geth and parity account functions are crap and were a design mistake as a hindsight
Peteris Erins
@Pet3ris
@miohtama what if I don't have the private key but just want to simulate the transaction?
is that supported by the eth-tester or web3.py interface or would it require forking/monkey patching at the py-evm level?
Mikko Ohtamaa
@miohtama
you cannot simulate a transaction wtihout a private key
just generate one
it is a random 256-bit integer
random.randit(1, 2**256) and job done
Peteris Erins
@Pet3ris
@miohtama sure - the problem I'm trying to solve is to simulate a transaction from an account I don't own. I know this is not perfectly possible in the general case, however, in many cases a good result can be obtained. How would one initiate a transaction like that?
Eth-Gitter-Bridge
@Eth-Gitter-Bridge
<carver, Jason Carver> Yeah, unfortunately, it will require some hacking for now. Nothing supported out of the box. The relevant piece in py-evm is how it handles a call and estimating gas, which both allow execution of transactions with spoofed senders (SpoofTransaction)
Mikko Ohtamaa
@miohtama
@Pet3ris Ganache has support for this
You can even fork the mainnet and take control over it to simulate behavior
However the problem "simulate a transaction account from an account you do not own" sounds like you need to have more context for what you are doing